Create a New Session Id After Each Trans in Same Window

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dickey
Forum Commoner
Posts: 50
Joined: Thu May 16, 2002 8:04 pm
Location: Sydney, Australia

Create a New Session Id After Each Trans in Same Window

Post by dickey »

Code: Select all

// start session
session_start();

// unset all of the session variables.  
  $_SESSION = array();

// if a (client side) cookie is set, expire it (as of 1 hr ago)
  if (isset($_COOKIEїsession_name()])){
  setcookie(session_name(), '$_COOKIEї'cookiename']' , time()-3600, '/');}

// destroys all of the data associated with the current session. It does not unset any of the global variables associated with the session, or unset the session cookie.
  session_destroy();
In a nutshell I have a four step workflow app.

The session starts when step 1 posts to step 2 and the session continues through steps 3 and 4.

Upon completion the user is returned to a page where the above code is run.

I create sessions using session_start().

The problem is that the session id either persists (i.e. the script has failed to expire/delete the cookie) or the session_id is re-instated for the same browser window for a new session.

The goal is to use a single browser window, to effectively 'logout' of a session, and create a new session_id after each transaction.

Any assistance greatly appreciated.


- Andrew
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

haven't heard of session_destroy(), have ya!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

your code has a parse error, and logic errors.. both in setcookie()

session_regenerate_id()
Post Reply