Sessions and cookies


Sessions mechanism is pretty simple. It's composed of two functions for initiating and stopping them, and an object which contains data.
For starting a session or using an already started one, call c.session_start(); at the beginning of your dynamic page.
You can then store data in the c.session object.

c.session_start();			// Retrieve the session.
c.session['key'] = 'value';	// Create/Modify a session variable.
delete c.session['key'];	// Remove a session variable.

You can also stop an existing session, or force the use of a new one.

c.session_start(true);	// Start an empty session.
c.session_stop();		// Stop the session.


You can access cookies sent by the client with the c.cookie object.
Cendre natively has a method to create and delete cookies sent by the client.

c.cookie['name'];						// Access to an existing cookie.
c.cookie_set('name', 'value', 3600);	// Add a cookie. The name and value must be a string. The lifetime is a number in seconds.
c.cookie_unset('name');					// Remove a cookie.

The lifetime is optionnal. If you don't set it, it will be deleted by the client when it's own session become over. There is no link with Cendre sessions here.
NB : The c.cookie object is not immediately updated. It will be the case at the next client request.