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

cookie class to retrieve cookie name from current page

Hi All,


I am writing a controller where i have a search field on VF page.when a text is entered in search area and clicked on search button , it looks for an existing cookie.If the cookie exist it goes to url A otherwise to url B.but when i used it in my page, the error is "System.NullPointerException: Attempt to de-reference a null object" .Please help me


My code :

public class searchingtest
public string searchtext{get;set;}

public PageReference searchbutton()
Cookie Name= ApexPages.currentPage().getCookies().get('Name');
String cname=Name.getName();

PageReference pageRef1 = new PageReference('');
return pageRef1;


PageReference pageRef2 = new PageReference('');
return pageRef2;



Wherer do you get the error? In which line i mean? You should have an email in your inbox with more details.






I just need to know how to retrieve the current page cookie correctly .Can you please help me on this.

I think because i am not able to retrieve the current page cookie name correctly , i am getting this error.