In its simplest form, a PHP session allows data to be stored temporarily on the server and accessed throughout a user's time on the site. When that user leaves the site or is inactive for a certain amount of time, the data is destroyed.
Session class has already taken care of many aspects of session storage. It provides a very simple interface to store and retrieve data from the user's session.
Also, when multiple extensions run on a site, there is a possibility of running into naming conflicts in session variables. For this reason,
Session allows for the specification of a namespace that a var should be placed under.
Session::set('cart', $cart, 'uniqueName');
Much like in the
Request library, a default value can be specified in the get() method as the second argument.
// Return an empty array if no data found $cart = Session::get('cart', array());