Forum Moderators: coopster

Message Too Old, No Replies

Using variables inside sessions

         

casinoverdiener

10:30 am on Mar 30, 2009 (gmt 0)

10+ Year Member



Hi,
I want to set sessions with names depending on a php variable id. What I thought would work is:

$_SESSION[$ID]=1;

But the session isn't set. At least I can't call it using:

$_SESSION[$ID];

What should I do instead?

Thanks.

Regards
Henrik

d40sithui

2:50 pm on Mar 30, 2009 (gmt 0)

10+ Year Member



It should work. I see nothing wrong here. Did you forget to do a session_start()? Do a print_r($_SESSION) to see all session data.

casinoverdiener

3:18 pm on Mar 30, 2009 (gmt 0)

10+ Year Member



Hi,
Thanks.
With help from print_r($_SESSION) I figured out that the variable couldn't be just a number. So I added some text "id" in front of the number, and it works:

$sessionID = "id".$ID;
$_SESSION[$sessionID]=1;

Kind regards