ana9 Posted December 15, 2006 Share Posted December 15, 2006 I have the following on a page: (I have session_start(); on all pages)<?phpsession_start(); if (isset($_SESSION['auth'])=="yes") { echo "<p> </p><p> </p><p align='center'><font face='verdana'>You are registered.</font></p>";}etc..... ?>so that when a user registers on another page if they hit the back button they cannot register a second time.The person is redirected to a second page where their info is inserted into the mssql database then I call: $_SESSION['auth']="yes"; to set the variableWhen I run this setup on my local machine it works perfectly, however when I put it up on the server it does not work. I am running sqlserver2005, windows server 2003, IIS6, php5. Link to comment https://forums.phpfreaks.com/topic/30815-solved-cant-get-_session-working/ Share on other sites More sharing options...
fert Posted December 15, 2006 Share Posted December 15, 2006 [code]if (isset($_SESSION['auth'])=="yes")[/code]should be[code]if ($_SESSION['auth']=="yes")[/code] Link to comment https://forums.phpfreaks.com/topic/30815-solved-cant-get-_session-working/#findComment-142069 Share on other sites More sharing options...
ana9 Posted December 18, 2006 Author Share Posted December 18, 2006 I had that code originally and I would get an error the first time the page was loaded because there was no value for the variable. By putting in the ISSET it eliminated the error and everything was working fine until I put it on the server. Link to comment https://forums.phpfreaks.com/topic/30815-solved-cant-get-_session-working/#findComment-143573 Share on other sites More sharing options...
redbullmarky Posted December 18, 2006 Share Posted December 18, 2006 but isset does exactly that - it tells you if a var is set (ie, holds a value). [url=http://www.php.net/isset]isset[/url] returns either true or false. so what your check actually equates to is:if TRUE/FALSE == 'yes'which will always fail.using both a check of being set as well as a check of its value should work:[code]<?phpif (isset($_SESSION['auth']) && $_SESSION['auth'] == "yes")?>[/code]hope that helpsCheersMark Link to comment https://forums.phpfreaks.com/topic/30815-solved-cant-get-_session-working/#findComment-143579 Share on other sites More sharing options...
ana9 Posted December 18, 2006 Author Share Posted December 18, 2006 That did the trick, thanks Mark. Link to comment https://forums.phpfreaks.com/topic/30815-solved-cant-get-_session-working/#findComment-143807 Share on other sites More sharing options...
redbullmarky Posted December 18, 2006 Share Posted December 18, 2006 ;) no probs Link to comment https://forums.phpfreaks.com/topic/30815-solved-cant-get-_session-working/#findComment-143827 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.