make session lifetime configurable
This commit is contained in:
parent
c0a39cb2a1
commit
2391415969
|
@ -345,6 +345,9 @@ return [
|
||||||
|
|
||||||
// Cookie name
|
// Cookie name
|
||||||
'name' => env('SESSION_NAME', 'session'),
|
'name' => env('SESSION_NAME', 'session'),
|
||||||
|
|
||||||
|
// Lifetime in days
|
||||||
|
'lifetime' => env('SESSION_LIFETIME', 30)
|
||||||
],
|
],
|
||||||
|
|
||||||
// IP addresses of reverse proxies that are trusted, can be an array or a comma separated list
|
// IP addresses of reverse proxies that are trusted, can be an array or a comma separated list
|
||||||
|
|
|
@ -62,6 +62,7 @@ class SessionServiceProvider extends ServiceProvider
|
||||||
'options' => [
|
'options' => [
|
||||||
'cookie_httponly' => true,
|
'cookie_httponly' => true,
|
||||||
'name' => $sessionConfig['name'],
|
'name' => $sessionConfig['name'],
|
||||||
|
'cookie_lifetime' => (int)($sessionConfig['lifetime'] * 24 * 60 * 60),
|
||||||
],
|
],
|
||||||
'handler' => $handler,
|
'handler' => $handler,
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -53,13 +53,19 @@ class SessionServiceProviderTest extends ServiceProviderTest
|
||||||
[Session::class],
|
[Session::class],
|
||||||
[
|
[
|
||||||
NativeSessionStorage::class,
|
NativeSessionStorage::class,
|
||||||
['options' => ['cookie_httponly' => true, 'name' => 'session'], 'handler' => null],
|
[
|
||||||
|
'options' => ['cookie_httponly' => true, 'name' => 'session', 'cookie_lifetime' => 172800],
|
||||||
|
'handler' => null
|
||||||
|
],
|
||||||
],
|
],
|
||||||
[Session::class],
|
[Session::class],
|
||||||
[DatabaseHandler::class],
|
[DatabaseHandler::class],
|
||||||
[
|
[
|
||||||
NativeSessionStorage::class,
|
NativeSessionStorage::class,
|
||||||
['options' => ['cookie_httponly' => true, 'name' => 'foobar'], 'handler' => $databaseHandler],
|
[
|
||||||
|
'options' => ['cookie_httponly' => true, 'name' => 'foobar', 'cookie_lifetime' => 432000],
|
||||||
|
'handler' => $databaseHandler
|
||||||
|
],
|
||||||
],
|
],
|
||||||
[Session::class]
|
[Session::class]
|
||||||
)
|
)
|
||||||
|
@ -101,8 +107,8 @@ class SessionServiceProviderTest extends ServiceProviderTest
|
||||||
->method('get')
|
->method('get')
|
||||||
->with('session')
|
->with('session')
|
||||||
->willReturnOnConsecutiveCalls(
|
->willReturnOnConsecutiveCalls(
|
||||||
['driver' => 'native', 'name' => 'session'],
|
['driver' => 'native', 'name' => 'session', 'lifetime' => 2],
|
||||||
['driver' => 'pdo', 'name' => 'foobar']
|
['driver' => 'pdo', 'name' => 'foobar', 'lifetime' => 5]
|
||||||
);
|
);
|
||||||
|
|
||||||
$app->expects($this->atLeastOnce())
|
$app->expects($this->atLeastOnce())
|
||||||
|
|
Loading…
Reference in New Issue