I have a PHP script which checks on a _SESSION variable (upon creating a session, I’m setting the following var $_SESSION[‘LAST_ACTIVITY’]=time() ).
The script has access to the relevant session id.
It sets the session id, starts the session, and checks the variable.
When I run the script manually, it works perfectly. It starts the session the was previously started and retrieves the _SESSION variable.
However, when the same script runs via CRON, the _SESSION variable is not set…
Any idea why?
when you call
session_start(), php looks for the session id in $_COOKIE, and sometimes $_REQUEST. These dont exist on the command line version, as there’s no webserver.You can manually specify the session id via
session_start($id);make sure the
session.save_pathsetting is the same between webserver and command line php versions. They can be different. Check via phpinfo() on both versions.