Bug 47476 - [mod_session] Cannot renew stored session
Summary: [mod_session] Cannot renew stored session
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: Other Modules (show other bugs)
Version: 2.5-HEAD
Hardware: All All
: P3 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks: 47477
  Show dependency tree
 
Reported: 2009-07-06 01:05 UTC by Alexey Varlamov
Modified: 2013-10-28 12:09 UTC (History)
1 user (show)



Attachments
Suggested fix to the problem. (939 bytes, patch)
2009-07-06 01:05 UTC, Alexey Varlamov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Varlamov 2009-07-06 01:05:00 UTC
Created attachment 23933 [details]
Suggested fix to the problem.

Once mod_session saves a session (to cookie), the session expiration cannot be reset - the only way to delete and re-create cookie anew. 

Accordingly to documentation:
"The SessionMaxAge directive defines a time limit for which a session will remain valid. When a session is saved, this time limit is reset and an existing session can be continued."
However tests and code inspection show that the expiry can be set just once and later updates do not refresh the session.
Also, "Max-Age" value for the updated session cookie is not passed to a user agent.

Please see the suggested fix attached.
Comment 1 Nick Kew 2009-07-06 02:03:20 UTC
Yow!  Those functions are a bit of a confusing mess (declared int, return apr_status_t - ouch).  Which should it be?

The second half of your patch looks obviously right.  But are you sure the first half won't also update the expiry when that wasn't intended?
Comment 2 Alexey Varlamov 2009-07-06 22:32:14 UTC
Actually there are 2 interconnected issues. As I said, original code did not reset expiry AND was dropping "Max-Age" value when updating session.
The first chunk of the patch only changes maxage setting logic, the expiry handling is not changed:
< earlier the maxage was only set if a new session is created or a session encountered which does not have expiry while it should per configuration (AFAIU only possible if server gets re-configured adding MaxAge and user comes with older cookie w/o expiry); and normally loaded sessions had maxage=0 (as maxage is not included to session encoding)
--
> now maxage is set always when present in config.

So the first chunk is necessary preparation for the second one :) 
Otherwise, if loaded session is modified and saved but maxage is zero, it should expire immediately.

As for the mess in functions, indeed they are declared to return int - don't know why :)
Comment 3 Graham Leggett 2013-10-13 13:10:30 UTC
Fixed in trunk in r1531683, proposed for backport to v2.4.x.
Comment 4 Graham Leggett 2013-10-28 12:09:51 UTC
Backported to v2.4.7.