freelance84 Posted March 23, 2011 Share Posted March 23, 2011 I have 3 php's home.php createStep1.php createCheckPass.php createStep2.php home.php unsets some $_SESSION variables if they still exist from previous pages: if(!empty($_SESSION['ame'])) { unset($_SESSION['ame']); } if(!empty($_SESSION['ject'])) { unset($_SESSION['ject']); } if(!empty($_SESSION['ports'])) { unset($_SESSION['ports']); } if(!empty($_SESSION['session_age_range'])) { unset($_SESSION['range']); } createCheckPass.php gets some posted information from createStep1.php, checks everything is ok and if so sets the above session variables createStep2.php gets the session data set by createCheckPass.php and then gets to work with the user inputting data into the db. The odd problem If createCheckPass.php finds any problems with the posted data it redirects the user back to createStep1.php with the sessions set, createStep1.php then displays the errors with the info set in the sessions to the user and everything works ok. If however the user sends the form from createStep1.php with no problems and the createCheckPass.php passes the user onto createStep2.php, something strange happens... The sessions set by the createCheckPass.php are only ever unset at the home.php, yet somehow createStep2.php loses the sessions and therefore doesn't run. What is even stranger is if i comment out the unsetting of the sessions from the home.php, everything works fine and none of the sessions are lost. Really really odd :confused: Summary: createStep2.php is reading the unset session lines of code from home.php when never asked to. Has anyone ever come across anything like this before? Quote Link to comment https://forums.phpfreaks.com/topic/231510-sessions-unset-when-not-asked-to-be-unset-by-another-script-not-even-called/ Share on other sites More sharing options...
MrXHellboy Posted March 23, 2011 Share Posted March 23, 2011 I think i need some more code and a short really direct point to your issue, it confuses me with such long explanation without any more code Quote Link to comment https://forums.phpfreaks.com/topic/231510-sessions-unset-when-not-asked-to-be-unset-by-another-script-not-even-called/#findComment-1191365 Share on other sites More sharing options...
PFMaBiSmAd Posted March 23, 2011 Share Posted March 23, 2011 It would take having enough of your code that DUPLICATES the problem for anyone to be able to see or help with what it is doing. Just posting a small portion from one page where you are un-setting some variables doesn't help. Best guesses - 1) You are redirecting all over the place and your code is redirecting to the index.php page where you are un-setting the variables. 2) You don't have an exit; statement after one or more of your header() redirects and the code on the page continues to execute while the browser is requesting the new page and that code is clearing the variables. Quote Link to comment https://forums.phpfreaks.com/topic/231510-sessions-unset-when-not-asked-to-be-unset-by-another-script-not-even-called/#findComment-1191375 Share on other sites More sharing options...
freelance84 Posted March 23, 2011 Author Share Posted March 23, 2011 Ok, thanks i'll try and find the problem with that in mind... I think the site may be redirecting to the index.php at some point due to user type. Thanks (the scripts are a little big. I'll try and find the problem with those pointers though) Quote Link to comment https://forums.phpfreaks.com/topic/231510-sessions-unset-when-not-asked-to-be-unset-by-another-script-not-even-called/#findComment-1191378 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.