PHP Sessions Not working?

Make sure cookies are enabled so the second page actually re-creates the session of the first page instead of creating a new, empty one. Check out php.net/manual/en/session.idpassing.php for details.

Make sure cookies are enabled so the second page actually re-creates the session of the first page instead of creating a new, empty one. Check out php.net/manual/en/session.idpassing.php for details. EDIT Another possible cause for sessions not working as expected, especially if it only affects certain pages, is that you have accidental whitespace or other output before your first 'session_start() error.

I've run sample code and it does not work, but I've used sessions before on this same server, pages that are still hosted and working properly. – Josh May 1 '11 at 18:13 I had to clear the page cookie to get it to work. Thank you SO much for pointing me down the cookie path!

– Josh May 1 '11 at 18:24.

It looks like you are just redirecting the user to the second page without posting anything. You would want to set hidden variables and actually submit your form to the second page. Re-directing will lose all the post variables.

If you want to send variables to the second page with a redirect, you can use session variables or a GET variable passed in with the URL to the second page.

Maybe my formatting is confusing. My assignment is enclosed within if($_POST'act' == "Login"). Is this what you mean?

– Josh May 1 '11 at 17:17 I see you check for the variable, but the variable never makes it to the second page because of your redirect (Header/Location line) on the first page. When you redirect like that it does not pass any POST variables to the next page. So you would either have to pass it with a GET or with a SESSION variable to the next page.

Or you could use Javascript to submit the form from the first page to the second page, but I suggest a session variable in case people do not have Javascript enabled. – Mikecito May 1 '11 at 17:34 That's what he's doing - just before the redirect, he assigns values to $_SESSION. Problem is, $_SESSION is empty on the subsequent page.

– Thilo May 1 '11 at 17:44 Yeah, the assignments are there, but he is still checking for POST variables on the second page. Those will always be null unless he posts something to it. – Mikecito May 1 '11 at 17:52 That's true, but I'm assuming he's looking for the $_SESSION'user'.

Josh, can you clarify in your question which line of your page 2 is not working as expected? – Thilo May 1 '11 at 18:04.

Try using $_SESSION'myvariable' = ' in upper case.

Yeah trusting someone elses test code was probably a mistake. I sent that file to the recycle bin! Thanks anyway though :) – Josh May 1 '11 at 18:25.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions