Hai Friends,
I need to maintain more sessions in the project.
Is there any possibility to maintain more than one session in the project.
Please give me an advice.
Thank you friends,
Multiple sessions
Moderator: General Moderators
What is the reason for multiple sessions..
if it is hold multiple variables in the session with the same name you could do this:
since the session variable is an array $_SESSION['key']=$value; you could do $_SESSION['session_one']['varialbe']=something and $_SESSION['session_two']['var']=somethingelse; .... read up on working with multi-demensional arrays
this should output:
You can alter the code an add on to it and do this:
if it is hold multiple variables in the session with the same name you could do this:
since the session variable is an array $_SESSION['key']=$value; you could do $_SESSION['session_one']['varialbe']=something and $_SESSION['session_two']['var']=somethingelse; .... read up on working with multi-demensional arrays
Code: Select all
<?php
session_start();
?><pre><?
$_SESSION['test']['hi']="bye";
print_r ($_SESSION);
?></pre>this should output:
Code: Select all
Array
(
їtest] => Array
(
їhi] => bye
)
)Code: Select all
Array
(
їsession1] => Array
(
їusername] => blah
)
їsession2] => Array
(
їusername] => blah
)
)