Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Bart Simpson
Cookie Age is always -1
January 9, 2012 5:21 AM
Answer

Bart Simpson

Rank: Liferay Master

Posts: 524

Join Date: August 29, 2011

Recent Posts

Perhaps a very basic question, when I try to create a cookie in use setMaxAge(5000) it's always set to -1
There doesn't seem a way to change the age of an existing cookie either.
Shinn Lok
RE: Cookie Age is always -1
January 9, 2012 1:29 PM
Answer

Shinn Lok

LIFERAY STAFF

Rank: Junior Member

Posts: 86

Join Date: January 14, 2011

Recent Posts

Hi Paul,

Are you adding the cookie after setting the max age?

1
2Cookie rememberMeCookie = new Cookie(CookieKeys.REMEMBER_ME, StringPool.BLANK);
3
4rememberMeCookie.setMaxAge(5000);
5
6CookieKeys.addCookie(request, response, rememberMeCookie);
Bart Simpson
RE: Cookie Age is always -1
January 9, 2012 11:40 PM
Answer

Bart Simpson

Rank: Liferay Master

Posts: 524

Join Date: August 29, 2011

Recent Posts

Yes, adding the cookie after setting the max age.
CookieKeys (isnt' it part of portal impl ? , not possible to use in plugins)
Apart from that I am using the same code as in CookieKeys.addCookie

My requirement is rather then modify an existing cookie then to create a new one. It doesn't seem possible. It's always set to -1.
Bart Simpson
RE: Cookie Age is always -1
January 12, 2012 1:43 AM
Answer

Bart Simpson

Rank: Liferay Master

Posts: 524

Join Date: August 29, 2011

Recent Posts

It's a simple thing to do, has anyone esle done it before?