Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Creating Custom Sessions


SuperPower09

Recommended Posts

I'm trying to find the osCommerce equivalent of the following:

session_start();

$_SESSION["custom_session"];

$_SESSION["custom_session"][$keys]["products_id"] - as you can see, I'm working with a session array.

Would anyone have insight on how to create custom sessions while using the osCommerce API?

I've checked the application_top.php and sessions.php, which gave me some ideas but I wasn't exactly certain.

Thank you in advance for any details here and I should add, if necessary, I'm totally comfortable with editing any core files...I know, I'm a rebel...

 

Link to comment
Share on other sites

In osCommerce, the session_start() is always done for you in includes/application_top.php.  You should not trigger it yourself.  It is done as early as possible. 

To do what you want, try

if (!tep_session_is_registered('custom_session')) {
  $GLOBALS['custom_session'] = [];
  tep_session_register('custom_session');
}

Then just use $GLOBALS['custom_session'] as you would normally.  If in global context (outside a class or function), you can access it as $custom_session.  You'd have to do this after tep_session_start is called.  And you probably should wait until after the extract($_SESSION , EXTR_OVERWRITE+EXTR_REFS );

Always back up before making changes.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...