Hi,

On Mon, Oct 7, 2019 at 3:14 AM Sibgha Nazir <sibgha...@gmail.com> wrote:

> Hi,
>
> I set a cookie from JavaScript in the chrome browser like
>
> > var d = new Date();
> > d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
> > var expires = "expires=" + d.toUTCString();
> > document.cookie = "test=true;1;path=/";
>

You don't use *expires *here.


>
>
> So the cookie value in the chrome is "true" (cookie "test"="true")
>
> then I am trying to clear the cookie in the wicket like
>
>   WebRequest webRequest = (WebRequest) RequestCycle.get().getRequest();
>
> WebResponse webResponse = (WebResponse) RequestCycle.get().getResponse();
>
> Cookie cookietest = webRequest.getCookie("test");
> > webResponse.clearCookie(cookietest);
>

This should work.
Check what are the response headers in Chrome's Dev Tools > Network. The
new max-age value must be set to 0.


>
>
> The cookie is not deleted. I run the wicket web app on tomcat server. Does
> anyone know what could be wrong?
>
>
> Just to be clear the cookie we set with JavaScript and the cookie we
> retrieve in wicket is pointing to the same space? I am confused why it
> wouldn't work. Does it have to anything with the Tomcat server?
>
> Best Regards,
> Sibgha Nazir
>

Reply via email to