+ Start a Discussion
Mar GeniusMar Genius 

One session(text-value) value for maintain multiple visualforce page

Hi All,  I just want to implement the one  session(text value) value across the multiple visual force pages and multiple controllers, Can anyone guide me on how to implement  
currently using cookies to maintain the one session value, is it correct?
Kancharla ChakravarthyKancharla Chakravarthy

Please use local storage functionality to maintain values between multiple pages

Use below code in VF pages
//You can refer class variable or can set text value
var pagevar = [{onesession:'{!accid}'];
//Set the local strage

// redirect to another vf page
// no need to pass the paramaters in teh URL as local storage will hold the values till you are in vf page screens 
   // Retrieve variables from local storgae
  var retrieveData = JSON.parse(localStorage.getItem('SessionVariable'));

 //call action function and pass parameters to apex pass for furthur execution       
 //Clear the local storage one the operation completed

<apex:actionFunction action="{!setLocalStorageParams}" name="setParams" reRender="formId">
        <apex:param name="accountId" assignTo="{!accountId}" value="" />
        <apex:param name="contactId" assignTo="{!contactId}" value="" />
        <apex:param name="customerFirstName" assignTo="{!customerFirstName}" value="" />
        <apex:param name="customerLastName" assignTo="{!customerLastName}" value="" />
        <apex:param name="customerEmailAddress" assignTo="{!customerEmailAddress}" value="" />                

Please choose as best answer if the above code works for you. It will help others to find the best answers