954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Session not persisting

Hello, I know you probably get quite a few threads asking this, but the DaniWeb search didn't pull up what I was looking for. So here we go:

I have a page that I've made as "private" by including my access control script at the top. The access control script starts a session, then checks to see if a username and password were POSTed, and if not, if they are in $_SESSION. If all that fails, then it displays the log in page. If it gets results though, it validates them against my MySQL database of usernames + passwords. If that all goes to plan, then it allows the page which included it to finish loading.

I can try to go to this "private" page, and the login page gets displayed instead, so I enter my username and password, which is correct so it displays the "private" page. When I click a link that takes me to the other "private" page, it displays the login form first again, and THEN the other private page when I've rePOSTed my info.

So obviously the problem I'm having is that my session data is not persisting (even though I assigned keys in $_SESSION after logging in). My php.ini file has a correct path to a temp folder to store the sessions in, and I can actually see the session file in that directory when I'm on the private page, yet it has 0 bytes of info in it.

I'm using EasyPHP 5.3.0 on Windows to test this out. Any help is appreciated! Thanks!


EDIT:
I am such an idiot. This problem had been bugging me for a while and I finally realized the dumbest mistake I had made. There was a "log out" link on the page, and its href was "<?php session_unset();?>" . I don't know how I ever thought that would executeonly when that link was clicked... let the laughing commence I guess :P

shadwickman
Posting Pro in Training
497 posts since Jul 2007
Reputation Points: 186
Solved Threads: 77
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: