Hm I copied your code into a new project:
public void onModuleLoad() {
final Date now = new Date();
now.setYear(now.getYear() + 1);
final String s = String.valueOf((new Date()).getTime());
Cookies.setCookie("last_accessed", s, now);
System.out.println(Cookies.getCookie("last_accessed")); //
prints
the same value over and
}
and hit reload several times. The output was
1289858621492
1289858627246
1289858631150
1289858632783
1289858634281
1289858635870
so the cookie value changes/increases on every reload. When inspecting
the cookie in browser preferences (Safari) it has an expire date one
year in the future. So I can't see any problems with your code
snippet. It should work.
On 15 Nov., 19:34, Viktoriya Sokolova <[email protected]>
wrote:
> I have actually tried to remove the cookie by setting it to empty
> string with expiration time in the past, but it still has the old
> value. Please help.
>
> On Nov 15, 1:04 pm, Viktoriya Sokolova <[email protected]>
> wrote:
>
>
>
> > Hi.
>
> > I am trying to reset last_accessed cookie value with a new timestamp
> > every time the page refreshes, and set the new future expiration date
> > (1 year ahead). The code below doesn't reset the cookie value. What
> > is the cleanest way to go about it?
>
> > final Date now = new Date();
> > now.setYear(now.getYear() + 1);
>
> > final String s = String.valueOf((new Date()).getTime());
> > Cookies.setCookie("last_accessed", s, now);
> > Cookies.getCookie("last_accessed"); // prints the same value over and
> > over
>
> > Thanks,
> > -Viktoriya
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.