I have been learning PHP for a little bit now, and it has been going really easy for the most part. The only thing I\'m hung up on is getting sessions to work. Google has be
It looks like you're not using session_start()
in your main_login.php like etranger alluded to. You need to call that function at the start of each new request to begin using sessions.
Otherwise, if you are calling session_start()
and you just neglected to show it in the code sample, then maybe the session ID is being lost during the redirect. Are you using cookie-based sessions or passing session ID as a URL parameter? Try printing session_id()
or SID
at the top of each page. This will let you know when the session is lost (the session ID will change or be "").
If you're using cookie-based sessions, then maybe the cookie is getting lost for some reason. If you're using URL parameter to pass session ID, then maybe transparent session ID support isn't working right.
You have to call session_start()
as early as possible, and definitely before using $_SESSION
, which would otherwise be empty.