Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

$_SESSION behavior


darp

Recommended Posts

Posted

I have made a number of files that rely heavily on $_SESSIONs. Users answer a few questions on a couple of forms, and this generates a list of suggested items that might meet their needs.

 

Their answers are passed to a review page via the $_SESSION variable. Their choices are reflected back at them. ( i.e. You would like to cover $_SESSION[‘sqft’] number of square feet.)

 

Everything works fine until that point. Then when I pass the $_SESSION on to the next file where it is to be used to calculate how much material the user needs $_SESSION[sqft] echos NULL. If is use print_r($_SESSION) the value is not there.

The code that $_SESSION[sqft] is used in is irrelevant, because even if I comment out everything and echo or var_dump() the $_SESSION variable standing alone, I get NULL.

 

This only happens when I place ‘application_top.php’ at the top of each file. If I place ‘session_start();’ at the top of the files $_SESSION[‘sqft’] retains its value.

 

However, using ‘session_start();’ establishes a new user session, and I would prefer to use the osCid session to track the users choices.

 

Can anyone tell me why this is happening and how I might get around it? Please keep it simple. I am pretty new at PHP.

 

Thanks for any help.

Posted

you have to set the session vars after you start a session. The osc does both. So look how it uses the tep_session_register like functions and do something similar.

Archived

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

×
×
  • Create New...