You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Mark Taylor <mt...@gmail.com> on 2015/09/03 15:51:45 UTC

mod_lua unable to delete cookie

Calling setcookie(..) with expires=0 does not set expires to the epoch time
on the client.

To delete a cookie client side, conventional wisdom is to set expires to
the epoch time:

http://stackoverflow.com/questions/5285940/correct-way-to-delete-cookies-server-side

When setting expires=0 in setcookie, modules/lua/lua_requests.c
lua_set_cookie() function skips adding the expires field to the cookie in
Set-Cookie header sent back to client.

The fix is pretty simple, time zero should be the epoch anyway?

-Mark

Re: mod_lua unable to delete cookie

Posted by Mark Taylor <mt...@gmail.com>.
That works, thanks!

-Mark

On Thu, Sep 3, 2015 at 8:56 AM, Daniel Gruno <hu...@apache.org> wrote:

> Hi Mark,
> you have to give it a number different from 0, because of how the
> internals work. This is an "optional integer" which falls back to 0 if
> nothing is given, and if 0, then it's not written.
> Set it to the past using os.time instead:
>
> r:setcookie{
>   key = 'foobar',
>   value = 'blah',
>   expipres = os.time() - 1
> }
>
> With regards,
> Daniel.
>
> On 09/03/2015 03:51 PM, Mark Taylor wrote:
> > Calling setcookie(..) with expires=0 does not set expires to the epoch
> time
> > on the client.
> >
> > To delete a cookie client side, conventional wisdom is to set expires to
> > the epoch time:
> >
> >
> http://stackoverflow.com/questions/5285940/correct-way-to-delete-cookies-server-side
> >
> > When setting expires=0 in setcookie, modules/lua/lua_requests.c
> > lua_set_cookie() function skips adding the expires field to the cookie in
> > Set-Cookie header sent back to client.
> >
> > The fix is pretty simple, time zero should be the epoch anyway?
> >
> > -Mark
> >
>
>

Re: mod_lua unable to delete cookie

Posted by Daniel Gruno <hu...@apache.org>.
Hi Mark,
you have to give it a number different from 0, because of how the
internals work. This is an "optional integer" which falls back to 0 if
nothing is given, and if 0, then it's not written.
Set it to the past using os.time instead:

r:setcookie{
  key = 'foobar',
  value = 'blah',
  expipres = os.time() - 1
}

With regards,
Daniel.

On 09/03/2015 03:51 PM, Mark Taylor wrote:
> Calling setcookie(..) with expires=0 does not set expires to the epoch time
> on the client.
> 
> To delete a cookie client side, conventional wisdom is to set expires to
> the epoch time:
> 
> http://stackoverflow.com/questions/5285940/correct-way-to-delete-cookies-server-side
> 
> When setting expires=0 in setcookie, modules/lua/lua_requests.c
> lua_set_cookie() function skips adding the expires field to the cookie in
> Set-Cookie header sent back to client.
> 
> The fix is pretty simple, time zero should be the epoch anyway?
> 
> -Mark
>