Thanks, Rod, appreciated. I still don't have the details straight though.
Originally Posted by
RodG
Because session_start() literally starts a new session.
In my case, yes. But most advice I'm able to find just puts a session_start() at the top of a page and the previous session is automatically resumed (such as here). What's unclear to me is how session_start() determines whether to resume a session or start a new one.
Originally Posted by
RodG
Either via the GLOBALS (classes) or the $_SESSION variables.
Each page load in Zen Cart includes a session_start() to resume the session and hence restore $_SESSION, so I can see how that works. For what I know that doesn't restore other superglobals, however, so how is info in $GLOBALS restored?
Originally Posted by
RodG
At the start of you module functions add
global $order ;
Unfortunately that does not work in my case. I'm using jQuery/ajax to retrieve info and update the shipping table based on the zip code entered. For what I can tell that requires the PHP script (sending a query to Amazon) to be in a separate file, and it can't see the Zen Cart variables - including superglobals.
A solution I thought would do the trick is to pass the session ID (retrieved with session_id() in tpl_modules_shipping_estimator.php) to my PHP script via the ajax GET call. I then start my script with:
PHP Code:
session_id($_GET['id']);
session_start();
That seems to work for others; in my case session_start still won't resume the session (i.e. $_SESSION is empty). I've verified that $_GET['id'] in my script does match the output of session_id() in tpl_modules_shipping_estimator.php. What am I doing wrong?
Bookmarks