Don't you wish there were an easy way to disable that?
Try appending this to your VF page name within your URL:
?core.apexpages.devmode.url=1
?core.apexpages.devmode.url=1
<apex:page contentType="application/msword">
<br clear="all" style="page-break-before:always" />
<apex:outputPanel id="CookieTest">
<apex:form >
Name:<apex:inputtext value="{!Name}"/>
<br />
<apex:commandButton action="{!addtocookie}" value="Add to Cookie"/>
<apex:commandButton action="{!ShowCookie}" value="ShowCookie" rerender="CookieTest"/>
<apex:commandButton action="{!ValidateCookie}" value="ValidateCookie"/>
<br />
The Name set in the cookie is : {!NameAtCookie}<br />
Max Age: {!MaxAge}
</apex:form>
</apex:outputPanel>
public with sharing class testCookie {
public string Name{get; set;}
public string NameAtCookie{get; set;}
public integer maxAge{get; set;}
public testCookie(test controller) {
}
public Pagereference addToCookie(){
InsertValueToCookie(Name);
return null;
}
public Pagereference ValidateCookie(){
SetCookieToNameAtCookies();
if(NameAtCookie == 'expired'){
pageReference pageRef = new pageReference('/apex/expired');
return pageRef;
}
else{
pageReference pageRef = new pageReference('/apex/not_expired');
return pageRef;
}
}
public Pagereference ShowCookie(){
SetCookieToNameAtCookies();
return null;
}
public void InsertValueToCookie(string val){
/* create a new cookie with name 'counter', an initial value of Name at the page,
path 'null', maxAge '-1', and isSecure 'false'.*/
Cookie myCookies=new Cookie('mycookie',val,null,-1,false);
ApexPages.currentPage().setCookies(new Cookie[]{myCookies});
}
public void SetCookieToNameAtCookies(){
/* reading the value of the cookie 'mycookie' , and insert him to 'NameAtCookie' field */
Cookie myCookies = ApexPages.currentPage().getCookies().get('mycookie');
if(myCookies != null){
NameAtCookie=myCookies.getValue();
maxAge=myCookies.getMaxAge();
}
else{
NameAtCookie='expired';
maxAge=null;
}
}
}
pageReference pageRef = new pageReference('https://na4.salesforce.com/apex/mypagename');
String hostname = ApexPages.currentPage().getHeaders().get('Host');
pageReference pageRef = new pageReference ('https://'+hostname +'/yourpagenamehere’);
system.debug('pageRef was: ';+ pageref);
return pageRef;
Copyright ©2005-2011 Acme, LLC. All Rights Reserved
Copyright ©2005-{!year(today())} Acme, LLC. All Rights Reserved