3

I have a cookie that is being dropped by an external service into my web browser (for example named my_cookie), that I would like to access within Salesforce. However, according to the documentation the getCookies() method

Only returns cookies with the "apex__" prefix set by the setCookies method.

So when I try to access with the getCookies() method:

Cookie counter = ApexPages.currentPage().getCookies().get('my_cookie');

the counter value is null, because it expects the cookie name to be named apex__my_cookie.

My only solution is to write a on page load javascript function that would copy my_cookie into a cookie named apex__my_cookie so it's accessible in Salesforce. Is this the only way to achieve what I want to do, or is there an alternative method I can use that doesn't require the javascript hack?

0

1 Answer 1

1

I'd suggest that you can't do it directly in Apex for a very specific reason - Security. If you can get to any cookie then you can start to pull values that Salesforce might not always want you to have.

If you do find a way to do it in Apex without client side manipulation of the cookies, I'd suggest running it past the Salesforce security team first.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .