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
Vishal_ThoriyaVishal_Thoriya 

How Check Cookie Exists Or Not?

hello i have a problem with cookies.

is there any way to check that this particular cookie exists or not ?

how can i check that ?

any kind of help will be appriciated.

Thanks in advance......

Best Answer chosen by Admin (Salesforce Developers) 
NzgonNzgon

See this for instructions how to use getCookie and setCookie

 

http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#CSHID=pages_compref_inputField.htm|StartTopic=Content%2Fpages_compref_inputField.htm|SkinName=webhelp

 

 



getCookies Map<String, System.Cookie[]>Returns a map of cookie names and cookie objects, where the key is a String of the cookie name and the value contains the list of cookie objects with that name. Used in conjunction with the cookie class. Only returnscookies with the “apex__” prefix set by the setCookies method.
setCookiesCookie[] cookiesVoidCreates a list of cookie objects. Used in conjunction with the cookie class.Important
  • Cookie names and values set in Apex are URL encoded, that is, characters such as @ are replaced with a percent sign and their hexadecimal representation.
  • The setCookies method adds the prefix “apex__” to the cookie names.
  • Setting a cookie's value to null sends a cookie with an empty string value instead of setting an expired attribute.
  • After you create a cookie, the properties of the cookiecan't be changed.
  • Be careful when storing sensitive information incookies. Pages are cached regardless of a cookievalue. If you use a cookie value to generate dynamic content, you should disable page caching. For more information, see Caching Force.com Sites Pages.
  • You can only create cookies and set cookie values for a page in the constructor for the page controller (see example).

All Answers

NzgonNzgon

See this for instructions how to use getCookie and setCookie

 

http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#CSHID=pages_compref_inputField.htm|StartTopic=Content%2Fpages_compref_inputField.htm|SkinName=webhelp

 

 



getCookies Map<String, System.Cookie[]>Returns a map of cookie names and cookie objects, where the key is a String of the cookie name and the value contains the list of cookie objects with that name. Used in conjunction with the cookie class. Only returnscookies with the “apex__” prefix set by the setCookies method.
setCookiesCookie[] cookiesVoidCreates a list of cookie objects. Used in conjunction with the cookie class.Important
  • Cookie names and values set in Apex are URL encoded, that is, characters such as @ are replaced with a percent sign and their hexadecimal representation.
  • The setCookies method adds the prefix “apex__” to the cookie names.
  • Setting a cookie's value to null sends a cookie with an empty string value instead of setting an expired attribute.
  • After you create a cookie, the properties of the cookiecan't be changed.
  • Be careful when storing sensitive information incookies. Pages are cached regardless of a cookievalue. If you use a cookie value to generate dynamic content, you should disable page caching. For more information, see Caching Force.com Sites Pages.
  • You can only create cookies and set cookie values for a page in the constructor for the page controller (see example).
This was selected as the best answer
Vishal_ThoriyaVishal_Thoriya

Thanks Nzgon for the help...