Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Session persistence problem

I'm having a problem with getting sessions to persist, and having no luck searching, I need to ask.

I can access the contents of my session as expected when first set, but as soon as the page refreshes I lose everything and I don't see why. session_start() is set and I'm not unseting or destroying anything. I looked at PHP Info under sessions and everything looks ok (but my understanding of sessions is limited).

I'm running MAMP on OS 10.5, and the last time I used sessions they worked.

like image 300
YsoL8 Avatar asked Nov 06 '22 14:11

YsoL8


1 Answers

as Josh has said, you'll want to check for the sessions existence first before you start making a new one, use an if statement to check for the $_SESSION variable, that should give you the results you want. a lil debugging trick i use is to do this:

if($_SESSION) {
   echo 'session exists';
else {
   echo 'does not exist';
}

This way i know instantly what code block is being called, without worrying about whats contained inside.

Hope this helps :)

like image 137
studioromeo Avatar answered Nov 12 '22 17:11

studioromeo