There are different way to run PHP code. For example user initiate reloads and user initiated ajax requests.
What it the best way to maintain state between these runs?
There are different way to run PHP code. For example user initiate reloads and user initiated ajax requests.
What it the best way to maintain state between these runs?
PHP does consider it separate runs. Two things:
$obj_ses = new session();
$obj_ses->activate('email', $this->_protected['email']);
The session id will be the same across all page views for that particular user, so creating a new session() in the second snippet will still refer to the same session you started in the first snippet.
Here's what a static implementation might look like:
// class names should be camel-cased
class SessionManager
{
protected static $session_id = null;
public static function start()
{
self::$session_id = session_start();
}
// ... and so on
}
// to use
SessionManager::start();
SessionManager::activate('email', $email);
That should really be all you need. There are certainly many ways to do this, but this ought to get you started :)