You need to sign in to do that
Don't have an account?

Pass cookie in PageReference?
I have a small controller that I'm using and I'm trying to figure out if there is a way I can pass a cookie to a visualforce page within a PageRefernece. I'd like the cookie to be available on my visualforce page so I can just do {!someCookieValue}.
Do I need to create another controller for the visualforce page I'm returning?
Here is the code:
Do I need to create another controller for the visualforce page I'm returning?
Here is the code:
public with sharing class pageController { public PageReference getTemplate() { Cookie someCookieValue = ApexPages.currentPage().getCookies().get('thecookie'); return Page.HomePageTemplate; } }
or pass data by viewstate by using a shared controller (both pages use same controller)
If it must be a cookie, then you could use a setCookie() on the refering page and on the landing page you could prob just receive like a parameter like: {!$CurrentPage.cookies.thecookie} (<-never tried that) if not then you can do by controller or use ApexPages.currentPage().getCookies().get('thecookie') with controller
ApexPages.currentPage().setCookies();
and use to getCookie
Cookie someCookieValue = ApexPages.currentPage().getCookies().get('thecookie');
I enterd up using the getCookies() and setCookies() methods as you all have suggested and it's working now!
Thanks!