multiple sessions per user

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
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

multiple sessions per user

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: multiple sessions per user

Post 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++;
}
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: multiple sessions per user

Post by php_east »

aha! and a separate cookie each to go with it. excellent :P thanks.
Post Reply