-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
46 lines (42 loc) · 1.34 KB
/
Copy pathfunctions.php
File metadata and controls
46 lines (42 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
/**
* Italix Session - Helper Functions
*
* @package Italix\Session
* @license MPL-2.0
*/
declare(strict_types=1);
namespace Italix\Session;
/**
* Describe the cookie the identifier travels in.
*
* cookie_spec('__Host-session')
* ->secure()->http_only()->same_site('Strict')->path('/');
*
* Defaults are the safe ones — `HttpOnly` on, `SameSite=Lax`, a session cookie
* rather than a persistent one — because the measurement that produced this
* library was a production application running on PHP's defaults, where every
* one of those was off and nobody had noticed.
*/
function cookie_spec(string $name_c): CookieSpec
{
return new CookieSpec($name_c);
}
/**
* Describe how long a session lives, in the three senses that differ.
*
* session_policy()->idle_ttl(600)->absolute_ttl(28800);
*
* For applications with a container, prefer registering the policy as a service
* and injecting it — this helper is for scripts, tests and configuration files,
* where wiring a container would be more ceremony than the job deserves.
*/
function session_policy(): SessionPolicy
{
return new SessionPolicy();
}