Sessions provide a very easy way to make data persistent without the need to constantly pass it through URL's or hidden form fields.It is used to store user data over certain period.It is stored on web server.
create session object.
Session object can be get by the getSession() method of JFactory class.
Getting Session ID
Session ID can be get from getId() method of JSession clas
$session->getId();
Storing Session Data
Session data can be stored using set() method of JSession class.
$session->set('place','delhi');
Check whether data exist in the Session store
By using has() method of jsession class.This method returns true if variable exists.
if($session->has('place'))
{
echo " yes ";
}
else{
echo " no ";
}
Where 'place' is the name of session variable.
JSession allows you to create your own namespace.
$session = JFactory::getSession();
$session->set('cart', $cart, 'uniqueName');
0 Comment(s)