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
DipakDipak 

How to create persistant Cookie

Actually, I am developing a Salesforce Sites application that has a requirement for creating a cookie that will persist if the Browser is closed and reopened. Using the APEX Cookies class it appears that only session cookies are created.

but when I am constructing a cookie I can enter  an integer value that represents the seconds that this cookie will persist within the browser.

 

for example 

Cookie commonFields = new Cookie('commonFields',Varible_Value,null,10000,false) 

 

But this cookie isn't persist after closing the browser. I need to persist this cookie after closing the browser.(here in the cookie value , i have set the varible value)

 

So how can i create persistent cookie

 

 

Thanks

aballardaballard

Cookies should be persistent.  A negative time value is supposed to create a session cookie.    Maybe something else is wrong?