dad00 Posted October 30, 2009 Share Posted October 30, 2009 Hi, Im making a login form and im using this code: if($login=="true"){ $_SESSION['mlvl']=1; if($username=="admin"){ $_SESSION['admin']=1; }else{ $_SESSION['admin']=0; } } but when the page refreshes their is no value on the sessions i get this output: Array ( [mlvl] => [admin] => ) any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/179672-sessions-value-not-saved/ Share on other sites More sharing options...
Stooney Posted October 30, 2009 Share Posted October 30, 2009 Do you have session_start(); at the top of the script? Quote Link to comment https://forums.phpfreaks.com/topic/179672-sessions-value-not-saved/#findComment-948007 Share on other sites More sharing options...
dad00 Posted October 30, 2009 Author Share Posted October 30, 2009 its in wordpress and yes ive put session_start in the right place (i modded wordpress to make sessions work) Quote Link to comment https://forums.phpfreaks.com/topic/179672-sessions-value-not-saved/#findComment-948056 Share on other sites More sharing options...
trq Posted October 30, 2009 Share Posted October 30, 2009 The problem is highly likely to be that session_start() is not called within all pages that make use of the $_SESSION array. Re-check it is in every page. Quote Link to comment https://forums.phpfreaks.com/topic/179672-sessions-value-not-saved/#findComment-948061 Share on other sites More sharing options...
PFMaBiSmAd Posted October 30, 2009 Share Posted October 30, 2009 That the array keys exist but the values are empty suggests you have some code that sets the values to an empty string. Any chance you have some code like if($_SESSION['mlvl'] = '') later in your file? Quote Link to comment https://forums.phpfreaks.com/topic/179672-sessions-value-not-saved/#findComment-948080 Share on other sites More sharing options...
dad00 Posted October 31, 2009 Author Share Posted October 31, 2009 no i dont, i tried it on my wamp server and it works fine but i try it on a host (host gator) and it has this problem Quote Link to comment https://forums.phpfreaks.com/topic/179672-sessions-value-not-saved/#findComment-948233 Share on other sites More sharing options...
PFMaBiSmAd Posted October 31, 2009 Share Posted October 31, 2009 When you don't state information that you know concerning the problem in your initial post, like what you just posted (i.e. under what conditions the problem occurs and under what conditions it does not) it takes a really long time for someone to help with what is actually causing your problem because they don't have all the relevant information about the who, what, when, where, and symptoms that are occurring. What does a phpinfo() statement show for the register_globals setting on both your WAMP server and on your live hosting? It your live server has the setting turned ON, then you likely have other post/get/cookie/program variables by the same name as your session variables and they are all overwriting each other. Assuming you don't have any other code that IS dependent on register_globals to work, you should turn off register_globals as soon as possible. They can be turned off in the master php.ini (assuming you have access to it), in a local php.ini (when php is running as a CGI application), or in a .htaccess file (when php is running as an Apache Module.) If the above does not correct the problem, what does a phpinfo() statement show for the output_buffering setting on both your WAMP server and your live host and we would need to see the full code on the page in order to determine what it could be doing to cause the symptoms for the various other possible server specific reasons. Quote Link to comment https://forums.phpfreaks.com/topic/179672-sessions-value-not-saved/#findComment-948310 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.