IntelliJ Java IDE
The moose likes Servlets and the fly likes Creating Persistent Cookie In Internet Explorer Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Creating Persistent Cookie In Internet Explorer" Watch "Creating Persistent Cookie In Internet Explorer" New topic
Author

Creating Persistent Cookie In Internet Explorer

sudipto shekhar
Ranch Hand

Joined: Apr 02, 2008
Posts: 771

Hi,

I have the following java code to create a cookie with expiry time of 1 year.



But when I close the browser (IE), I see all the cookies being deleted.

Can anyone help me creating persistent cookies for IE.

Any help is appreciated.


Regards, Sud.
SCJP 5 ScjpFAQ JLS
Pranit Sonawane
Ranch Hand

Joined: Jul 29, 2011
Posts: 48
Recompile...the program again!!!
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50691

Pranit Sonawane wrote:Recompile...the program again!!!

Ummm, yeah.


A persistent cookie should be created with a path specified. It could just be "/" to indicate the entire domain.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
sudipto shekhar
Ranch Hand

Joined: Apr 02, 2008
Posts: 771

Bear Bibeault wrote:
Pranit Sonawane wrote:Recompile...the program again!!!

Ummm, yeah.


A persistent cookie should be created with a path specified. It could just be "/" to indicate the entire domain.


Thank you for the reply.

I agree that the path that is specified while adding the cookie in response is the location where the cookies are stored.

I modified the code as follows:



So, when the IE is re-opened, those cookies should be visible. But I do not see the same cookies again.

Any comments ?
Rob Spoor
Saloon Keeper

Joined: Oct 27, 2005
Posts: 18370

Did you perhaps tell Internet Explorer to actively block cookies?


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
sudipto shekhar
Ranch Hand

Joined: Apr 02, 2008
Posts: 771

Rob Spoor wrote:Did you perhaps tell Internet Explorer to actively block cookies?


Using the plugin developer tools, I can see the cookies being added to the browser!
 
 
subject: Creating Persistent Cookie In Internet Explorer
 
Threads others viewed
change cookie value
cookie.getMaxAge reads -1
Cookie access with EL expression
how to set the "remember me" checkbox in the jsp
Can't read cookie from another page!
IntelliJ Java IDE