function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rani_RRani_R 

How to persist some values across tabs and pages in salesforce

Hi,

 

I have a tab "Document Management" and i have associated a VF Login page to this tab.... when user logs in here i call a jsp and i get a  cookie back in my response, which i have to embed in my next requests..

 

When user logs in successfully, i am redirecting to a new VF INDEX page in the same tab.... so i am passin the cookie parameters in the query string to the second page... here i dont have any problems...

 

But if i visit a new tab, say accounts tab or contacts tab and then return to my Document Management tab, the first Login page gets displayed..... I need to know somehow that user has already logged in before, so i have to redirect the user directly to the INDEX page... so where can i put the cookie values that i got in my first login request? is there any session like we have in java or .net that will be persisted always....

 

Also i have a small pageblock in the contacts and accounts detail page.. .so when user goes to contacts tab and selects a contact there, i should know whether the user has already logged in Document management tab, if he has logged in i should display the documents in that paeg block, else i have to ask user to login there....

 

I hope i have explained properly... i want to persist some details like whether user has logged in and his id all those things in session kind of thing...

 

Please help me and let me know how i can achieve this...

 

Thanks and Regards,

Rani.....

Best Answer chosen by Admin (Salesforce Developers) 
AhmedPotAhmedPot

Hi,

 

We cannot store session in any variables similar to Java/.Net.

 

check this below link,

http://boards.developerforce.com/t5/Visualforce-Development/Storing-and-Accessing-of-Session-variables-in-APex-Page-aswell/m-p/154083

 

You can use custom settings or custom object, to store login details.And may be write a scheduled class which will say check if login time is more than 60 minutes, so it will update login status/flag to false.

 

So next time if you try to view the page, then it will ask you to login again.

 

Hope this can help you.

 

Thanks,

Ahmed

All Answers

AhmedPotAhmedPot

Hi,

 

We cannot store session in any variables similar to Java/.Net.

 

check this below link,

http://boards.developerforce.com/t5/Visualforce-Development/Storing-and-Accessing-of-Session-variables-in-APex-Page-aswell/m-p/154083

 

You can use custom settings or custom object, to store login details.And may be write a scheduled class which will say check if login time is more than 60 minutes, so it will update login status/flag to false.

 

So next time if you try to view the page, then it will ask you to login again.

 

Hope this can help you.

 

Thanks,

Ahmed

This was selected as the best answer
Rani_RRani_R

Ahamed,

 

Thanks for your reply..

 

Please let me knw which one to use.. custom object or custom setting? because i dont have any idea about both of them, i want to start reading, so it will be better to start with the one which will be fast usefull to me..

 

Thanks

Rani

AhmedPotAhmedPot

You can use custom settings. Advantage of using custom settings is that values are stored in cache, so there is no need to use SOQL query to retrieve it.

 

Maximum size is 2MB is allowed per org with custom settings.

 

 

Rani_RRani_R

Ok Ahmed.

 

Thanks. :)