shiro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Grigorov (JIRA)" <>
Subject [jira] [Commented] (SHIRO-520) Multiple Set-Cookie headers for the same cookie
Date Mon, 29 Sep 2014 08:57:34 GMT


Martin Grigorov commented on SHIRO-520:

Yes, my description is about logout+login.
For login only just setting the new new cookie value should be enough. There is no need of
the one with maxAge=past.

I guess somewhere in Shiro's code there is response.addHeader("Set-Cookie") which should be
substituted with .setHeader(). 

> Multiple Set-Cookie headers for the same cookie
> -----------------------------------------------
>                 Key: SHIRO-520
>                 URL:
>             Project: Shiro
>          Issue Type: Bug
>          Components: Web
>    Affects Versions: 1.2.1, 1.2.2
>            Reporter: Sebastian Ganslandt
> When stopping an old session and starting a new one in the same API request like 
> {noformat}
> public boolean login() {
>   SecurityUtils.getSubject()
>   session.stop()
>   UsernamePasswordToken token = new UsernamePasswordToken(username, plaintextPassword);
>   subject.login(token);
> }
> {noformat}
> the response headers will include two Set-Cookie entries, one which removes the old session
id (value=deleteMe and expiryTime=<in the past>) and one which sets the new session
id. This seems to have been fine previously but for example Safari on iOS 8 seems to reverse
the order of them when handling the response and effectively making it impossible to stay
> According to, "Servers SHOULD NOT include more than
one Set-Cookie header field in the same response with the same cookie-name.". If they do,
the client can/will just override the cookie value from subsequent Set-Cookie headers. Sending
multiple Set-Cookie headers would then make the correct functionality be dependent on the
client sorting the headers correctly which brings us to (from the same RFC)
> 2.  The user agent SHOULD sort the cookie-list in the following
>        order:
>        *  Cookies with longer paths are listed before cookies with
>           shorter paths.
>        *  Among cookies that have equal-length path fields, cookies with
>           earlier creation-times are listed before cookies with later
>           creation-times.
>        NOTE: Not all user agents sort the cookie-list in this order, but
>        this order reflects common practice when this document was
>        written, and, historically, there have been servers that
>        (erroneously) depended on this order.
> For (just a little) more context, see

This message was sent by Atlassian JIRA

View raw message