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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.