severndigital Posted November 9, 2007 Share Posted November 9, 2007 I have two things happening .. when the user logsin .. I am registering sessions automatically with this code $item = array($var1,$var2,$var3,$var4); function registerSessions($item){ foreach($item as $key => $val){ session_register("$key"); $_SESSION["$key"] = $val; } }//END registerSessions this loads sessions that when I echo all the sessions I get duplicates. foreach($_SESSION as $key => $val){ echo "This is session: $key value = $val<BR>"; } returns this: This is session: 0 value = This is session: 0 value = 0 This is session: 1 value = This is session: 1 value = 1 This is session: 2 value = This is session: 2 value = 2 This is session: 3 value = This is session: 3 value = 3 This is session: 4 value = This is session: 4 value = 4 Why is it showing the session twice?? The rest of my code is only pulling the first session .. so if session[0] is empty .. nothing happens. when I navigate to another page and run the same foreach statement. I only get this This is session: 0 value = The session is registered because the number is there session[0]. but it has no value. any ideas?? thanks, chris Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 9, 2007 Share Posted November 9, 2007 instead of a foreach, do this: print_r($_SESSION); You will need to look at the source code to see the formatted version. Quote Link to comment Share on other sites More sharing options...
severndigital Posted November 9, 2007 Author Share Posted November 9, 2007 it still displays duplicates of the sessions Array ( [0] => [0] => 0 [1] => [1] => 1 [2] => [2] => 2 [3] => [3] => 3 [4] => [4] => 4 ) Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 9, 2007 Share Posted November 9, 2007 remove this: session_register("$key"); session_register() is deprecated Quote Link to comment Share on other sites More sharing options...
severndigital Posted November 9, 2007 Author Share Posted November 9, 2007 Ahhh .. yeah .. that solved the duplicate problems.. thank you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.