Page 1 of 1

Multiple sessions

Posted: Wed Nov 10, 2004 3:51 am
by appu
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,

Posted: Wed Nov 10, 2004 5:39 am
by josh
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


Code: Select all

<?php

session_start();
?><pre><?
$_SESSION['test']['hi']="bye";
print_r ($_SESSION);
?></pre>

this should output:

Code: Select all

Array
(
    &#1111;test] =&gt; Array
        (
            &#1111;hi] =&gt; bye
        )

)
You can alter the code an add on to it and do this:

Code: Select all

Array
(
    &#1111;session1] =&gt; Array
        (
            &#1111;username] =&gt; blah
        )
    &#1111;session2] =&gt; Array
        (
            &#1111;username] =&gt; blah
        )

)