Skip to main content
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
2 answers
  1. May 8, 2017, 4:52 PM
    Following Details can help you for storing data in session on Salesforce force.com public sites.....

    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/)

     
0/9000