Multiple Cookies

H

HugeBob

Hi All,

Why does the following code generate multiple cookies:

Cookie c = new Cookie("bgColor", bgColor);
c.setMaxAge(300); // Five minutes
c.setPath("/");
response.addCookie(c);

I added the c.setPath() command thinking that that was the issue. But
I was wrong. I would think that the cookie would be overwritten.
Also, FireFox says the cookies expire "at end of session" when it
should end in 5 minutes.
 
J

John B. Matthews

HugeBob said:
Why does the following code generate multiple cookies:

Cookie c = new Cookie("bgColor", bgColor);
c.setMaxAge(300); // Five minutes
c.setPath("/");
response.addCookie(c);

I added the c.setPath() command thinking that that was the issue.
But I was wrong. I would think that the cookie would be overwritten.
Also, FireFox says the cookies expire "at end of session" when it
should end in 5 minutes.

Does your servlet container perhaps use a cookie for session tracking? I
recall being surprised that mine did so by default.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top