Jump to content

sessions unset when not asked to be unset by another script not even called


freelance84

Recommended Posts

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: :confused: :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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.