This repository has been archived by the owner on Jan 29, 2020. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PHP supports persistent sessions by allowing developers to set the
session.cookie_lifetime
value, or to pass the$lifetime
argument tosession_set_cookie_params()
. In each case, ext-session will then set anExpires
directive in theSet-Cookie
header associated with the session. These values are often manipulated at runtime to allow developers to set session cookie lifetimes based on specific criteria (e.g., a user checking a "remember me" box).This patch adds the ability for developers to provide at runtime a TTL for the sesssion they are manipulating. It introduces a new interface,
SessionCookiePersistenceInterface
, with the methodspersistSessionFor(int $duration) : void
andgetSessionLifetime() : int
. The first can be used by developers to indicate the desired session lifetime; the second can be used by persistence engines in order to set the lifetime either in the persistence engine itself or in client-side artifacts such as session cookies.In order to allow the lifetime to persist when a cookie is regenerated, I both recommend that the session stores the lifetime within its own data, and that
Session
instances use that value when present. I have implementedSession
such that it does exactly this, using the value ofSessionCookiePersistenceInterface::SESSION_LIFETIME_KEY
as the session data key under which the lifetime is stored.The value is specified and stored as an integer, as most existing systems expect an integer indicating the number of seconds the session should persist. Negative values and zero indicate expiry as soon as the current session is over (generally indicated by closing the window and/or browser).