You need to sign in to do that
Don't have an account?
Pradip Kr. Shukla
Any Idea on storing data in session on Salesforce force.com public sites?
Hi Guys,
While developing visualforce pages for force.com public sites i want to store some values in session from apex controller.
I used Cache.Session / Cache.SessionPartition but this is only working internally, not working on public sites.
Code lines are below-
Cache.SessionPartition sessionPart = Cache.Session.getPartition('local.myPartitionSession');
// Retrieve cache value from the partition
if (!sessionPart.contains('BookTitle')) {
sessionPart.put('BookTitle', 'test');
}
Thanks.
Pradip Shukla
While developing visualforce pages for force.com public sites i want to store some values in session from apex controller.
I used Cache.Session / Cache.SessionPartition but this is only working internally, not working on public sites.
Code lines are below-
Cache.SessionPartition sessionPart = Cache.Session.getPartition('local.myPartitionSession');
// Retrieve cache value from the partition
if (!sessionPart.contains('BookTitle')) {
sessionPart.put('BookTitle', 'test');
}
Thanks.
Pradip Shukla
You need to use cookie class instead of Cache.Session/Cache.SessionPartition.
Refer below link for more info.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_sites_cookie.htm
Let me know if this helps :)
Thanks,
Amit Sigh
Cookie sessionStore= new Cookie('BookTitle',test’,null,-1,false); // provide data in 'BookTitle' =’test’
ApexPages.currentPage().setCookies(new Cookie[]{sessionStore}); //set value in cookie
// provide that value to string variable sessionData
String SessionData = ApexPages.currentPage().getCookies().get('BookTitle').getValue();
system.debug(‘SessionData ’+SessionData )
Return :- SessionData : test
Let me know if this is helpful ;)
Thanks
Daisy Scott
Salesforce Consultants (http://www.janbask.com/salesforce-consulting-services/)