Monday, 08 July 2013 22:47

how to use session in joomla

Written by 
Rate this item
(0 votes)

session is a essential part of joomla. It's main use
is for remembering user login, also there are many
usage of it.

1. how to store data in session? see below -

$msfbwall_user_session = JFactory::getSession(); // main call
$msfbwall_user_session->set('msfb_session_itemid',$_REQUEST['Itemid']);

here i saved current menu item id in a session variable "msfb_session_itemid"

2. how to check session var exists and get stored value ? see here -

if(($msfbwall_user_session->get('msfb_session_itemid')!=NULL)) //session not null
{
$msfb_mod= $msfbwall_user_session->get('msfb_session_itemid');
}

3. how to destroy a stored session value ? this way -

$msfbwall_user_session->clear('msfb_session_itemid');

this will remove the value stored in session variable "msfb_session_itemid"

hope it helps a lot.Dont forget to like and share it.

Read 1294 times Last modified on Monday, 08 July 2013 22:54
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.
Login to post comments