Jump to content

Problem with unset() and exit()


doubledee

Recommended Posts

I have a script that allows a User to create a new password as part of a password re-set flow.

 

In my script, I store the $memberID in the Session so that when I redirect from "create_password.php" to "results.php" I still have the $memberID and can store it in the transaction log in my database.

 

The problem is that even though I have unset() after the redirect, it is somehow erasing the value in $_SESSION['memberID'] before the redirect, and thus I get "0" in the database when "results.php" runs?!

 

// Temp Password expires in 1 hour (3600 seconds).
if ((time() - $tempResetOn)>10){
	// Temp Password Expired.
	$_SESSION['resultsCode'] = 'PASSWORD_TEMP_PASSWORD_EXPIRED_2112';

	// Set Error Source.
	$_SESSION['errorPage'] = $_SERVER['SCRIPT_NAME'];

	// Redirect to Outcome Page.
	header("Location: " . BASE_URL . "/members/results.php");

	unset($_SESSION['memberID']);

	// End script.
	exit();
}//End of CHECK FOR EXPIRED TEMP PASSWORD

 

How do I unset the Session variable - in the "create_password.php" script above - AFTER I successfully redirect and store the $memberID in the database?

 

Thanks,

 

 

Debbie

 

 

Link to comment
Share on other sites

The code keeps executing after the header() until the script ends.

 

So why not unset on the results page?

 

I could do that.

 

However, I think I was getting confused as to what to expect where, so disregard this thread for now.

 

Thanks anyways!

 

 

Debbie

 

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.