tecmeister Posted September 16, 2009 Share Posted September 16, 2009 Hi guys, I'm having a big problem with setting a session. I have tried to set a session on every page but nothing is happening. I have tried it on my online server and on localhost and still getting the same problem. All that is happening is: PHPSESSID what I use session_start(); Please will someone be able to help me with the problem? Thanks, tecmeister. Link to comment https://forums.phpfreaks.com/topic/174508-will-not-set-_session/ Share on other sites More sharing options...
sKunKbad Posted September 16, 2009 Share Posted September 16, 2009 Post some code so we can see what you are doing. Link to comment https://forums.phpfreaks.com/topic/174508-will-not-set-_session/#findComment-919737 Share on other sites More sharing options...
tecmeister Posted September 16, 2009 Author Share Posted September 16, 2009 example: session_start(); $_SESSION['something'] = "Something" Link to comment https://forums.phpfreaks.com/topic/174508-will-not-set-_session/#findComment-919739 Share on other sites More sharing options...
sKunKbad Posted September 16, 2009 Share Posted September 16, 2009 So what happens if you do this: print_r($_SESSION); Link to comment https://forums.phpfreaks.com/topic/174508-will-not-set-_session/#findComment-919741 Share on other sites More sharing options...
tecmeister Posted September 16, 2009 Author Share Posted September 16, 2009 Array ( [attemps] => 0 [test] => 0 ) Link to comment https://forums.phpfreaks.com/topic/174508-will-not-set-_session/#findComment-919743 Share on other sites More sharing options...
sKunKbad Posted September 16, 2009 Share Posted September 16, 2009 Well, so you do have a session array, and it is showing two keys that you must have set at some point. try this: echo '<h1>' . $_SESSION['test'] . '</0>'; You should see a big 0 Link to comment https://forums.phpfreaks.com/topic/174508-will-not-set-_session/#findComment-919747 Share on other sites More sharing options...
tecmeister Posted September 16, 2009 Author Share Posted September 16, 2009 I use this: if(isset($_SESSION['attemps'])){ echo "Then do this"; } else{ $this->attemps(); } and it keeps on doing the else. Link to comment https://forums.phpfreaks.com/topic/174508-will-not-set-_session/#findComment-919754 Share on other sites More sharing options...
MadTechie Posted September 16, 2009 Share Posted September 16, 2009 don't forget the session_start(); session_start(); if(isset($_SESSION['attemps'])){ echo "Then do this"; }else{ //$this->attemps(); $_SESSION['attemps'] = 1; echo "Refresh me"; } Link to comment https://forums.phpfreaks.com/topic/174508-will-not-set-_session/#findComment-919816 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.