Jump to content

[SOLVED] session problems


severndigital

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/76641-solved-session-problems/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.