Storing Session Data

PHPR's session class encapsulates the native PHP session. It is available in the global object Phpr::$session.

Storing data in a session

You can store session data like so:

Phpr::$session->set('key', 'value');

Accessing session data

Retrieving the value is just as easy:

Phpr::$session->get('key');

You can also retrieve an item with a default value, used when the key cannot be found:

Phpr::$session->get('key', 'default value');

Clearing session data

If you want to remove a single a single value:

Phpr::$session->remove('key');

Or if you want to clear the entire store of session data:

Phpr::$session->reset();