xiao Posted April 22, 2008 Share Posted April 22, 2008 Is it normal that all session variables get lost when the page is being refreshed? Link to comment https://forums.phpfreaks.com/topic/102420-solved-session-variables-get-lost-on-refresh/ Share on other sites More sharing options...
phpSensei Posted April 22, 2008 Share Posted April 22, 2008 Depends if your setting the session, without the session_start on top, then refreshing it, then no. Post your code. Link to comment https://forums.phpfreaks.com/topic/102420-solved-session-variables-get-lost-on-refresh/#findComment-524479 Share on other sites More sharing options...
DarkWater Posted April 22, 2008 Share Posted April 22, 2008 Are you setting your session variables equal to something from $_POST EVERY time the script runs? That'll cause you to overwrite your session vars with blank vars every time you refresh because the post data is gone. =P Link to comment https://forums.phpfreaks.com/topic/102420-solved-session-variables-get-lost-on-refresh/#findComment-524497 Share on other sites More sharing options...
xiao Posted April 22, 2008 Author Share Posted April 22, 2008 if(($_POST['processor'] != "(Make a choice)") && ($_SESSION['processor'] != $_POST['processor'])){ $_SESSION['processor'] = $_POST['processor']; } So it shouldn't overwrite everytime, right? It does though. i have a session_start(); (tried to remove it and got quite some errors) I don't have a session_destroy anywhere. I don't really get it... Link to comment https://forums.phpfreaks.com/topic/102420-solved-session-variables-get-lost-on-refresh/#findComment-524500 Share on other sites More sharing options...
DarkWater Posted April 22, 2008 Share Posted April 22, 2008 if(($_POST['processor'] != "(Make a choice)") && ($_SESSION['processor'] != $_POST['processor'])){ $_SESSION['processor'] = $_POST['processor']; } So it shouldn't overwrite everytime, right? It does though. i have a session_start(); (tried to remove it and got quite some errors) I don't have a session_destroy anywhere. I don't really get it... Yeah, because when you have a blank $_POST, $_POST['processor'] isn't "(Make a choice)", it's NULL. Get it? Link to comment https://forums.phpfreaks.com/topic/102420-solved-session-variables-get-lost-on-refresh/#findComment-524504 Share on other sites More sharing options...
xiao Posted April 22, 2008 Author Share Posted April 22, 2008 hmm, makes sense Thanks. makes me able to do another 20 minutes of programming. I'll be back with another silly question in a few minutes Link to comment https://forums.phpfreaks.com/topic/102420-solved-session-variables-get-lost-on-refresh/#findComment-524517 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.