Page 1 of 1

multiple sessions per user

Posted: Wed Mar 25, 2009 1:23 pm
by php_east
is it possible or allowable, technically speaking, to assign multiple session ids to one user ?
most user management systems already use session info, if i wanted to make some processing on my own, i would need to assign the current user a new session i.e. by session start() and this would be on top of what is already assigned/designated by the current app.

Re: multiple sessions per user

Posted: Wed Mar 25, 2009 1:59 pm
by requinix
No. One session per user.

However you can build an array in $_SESSION - "virtual sessions" if you will.

Code: Select all

$_SESSION["sessions"] = array(
    "first" => array("data 1", "data 2", "data 3"),
    "second" => array("data 4", "data 5", "data 6"),
    "third" => array("data 7", "data 8", "data 9")
);
 
$i = 1; foreach ($_SESSION["sessions"] as $name => $data) {
    echo "Active session $i: '", $name, "'<br/>\n";
    $i++;
}

Re: multiple sessions per user

Posted: Wed Mar 25, 2009 2:27 pm
by php_east
aha! and a separate cookie each to go with it. excellent :P thanks.