简体   繁体   中英

How to update session values in joomla?

I have a form.Now I want to save it's value to session, So I have set the session value when the form submitted like below.

if(JRequest::getVar('from')=='watches'){
    $session = JFactory::getSession();
    $post = JRequest::get('post');
    $session->set('wt_postdata',$post);
}

So the value are set to session variable wt_postdata . That's fine. Now I want that if user again visit the same form ,even if the current session not destroyed, user again submitted the same form with the new value ,so the new value will override the old value which stored previously. I want to know that is it possible to update/modify the session value?

If not is there any alternative by that I can temporarily stored the post data for later uses?

Please help.

I understand it is an old post but I thought to share the answer in case someone is looking for it.

In Joomla to Update the Session value you need to set the same variable name with the new value for example:

$session=JFactory::getSession();
$session->set('var1','x');
$session->set('var1','y');

Now, Var 1 is : y

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM