4
4
Session Proxy Examples
5
5
----------------------
6
6
7
- The session proxy mechanism has a variety of uses, this
8
- example demonstrates two common uses. Rather than injecting
9
- the session handler as normal, a handler is injected into the proxy
10
- and registered with the session storage driver::
7
+ The session proxy mechanism has a variety of uses and this example demonstrates
8
+ two common uses. Rather than injecting the session handler as normal, a handler
9
+ is injected into the proxy and registered with the session storage driver::
11
10
12
- <?php
13
11
use Symfony\Component\HttpFoundation\Session\Session;
14
12
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
15
13
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionStorage;
16
14
17
15
$proxy = new YourProxy(new PdoSessionStorage());
18
16
$session = new Session(new NativeSessionStorage($proxy));
19
17
20
- The examples below show elaborate on two use-cases.
18
+ Below, you'll learn two real examples that can be used for ``YourProxy ``:
19
+ encryption of session data and readonly guest session.
21
20
22
21
Encryption of Session Data
23
22
--------------------------
24
23
25
- If you wanted to encrypt the session data you could use the proxy to encrypt
24
+ If you wanted to encrypt the session data, you could use the proxy to encrypt
26
25
and decrypt the session as required::
27
26
28
- <?php
29
27
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;
30
28
31
29
class EncryptedSessionProxy extends SessionHandlerProxy
@@ -54,15 +52,13 @@ and decrypt the session as required::
54
52
}
55
53
}
56
54
57
-
58
- Readonly Guest sessions
55
+ Readonly Guest Sessions
59
56
-----------------------
60
57
61
- There are some applications where a session is required for guest
62
- users, but there is no particular need persist the session. In this
63
- case you can intercept the session before it writes::
58
+ There are some applications where a session is required for guest users, but
59
+ there is no particular need to persist the session. In this case you can
60
+ intercept the session before it writes::
64
61
65
- <?php
66
62
use Foo\User;
67
63
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;
68
64
@@ -86,4 +82,3 @@ case you can intercept the session before it writes::
86
82
return parent::write($id, $data);
87
83
}
88
84
}
89
-
0 commit comments