  We prove congruences between cuspidal newforms and Eisenstein series of prime
level, which generalize Ramanujan's congruence. Such congruences were recently
found by Billerey and Menares, and we refine them by specifying the
Atkin-Lehner eigenvalue of the newform involved. We show that similar
refinements hold for the level raising congruences between cuspidal newforms of
different levels, due to Ribet and Diamond. The proof relies on studying the
new subspace and the Eisenstein subspace of the space of period polynomials for
the congruence subgroup $\Gamma_0(N)$, and on a version of Ihara's lemma.
