|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* \AppserverIo\Psr\Servlet\Http\HttpSessionWrapper |
|
5
|
|
|
* |
|
6
|
|
|
* NOTICE OF LICENSE |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
|
9
|
|
|
* that is available through the world-wide-web at this URL: |
|
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
|
11
|
|
|
* |
|
12
|
|
|
* PHP version 5 |
|
13
|
|
|
* |
|
14
|
|
|
* @author Tim Wagner <[email protected]> |
|
15
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
|
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
17
|
|
|
* @link https://github.com/appserver-io-psr/servlet |
|
18
|
|
|
* @link http://www.appserver.io |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace AppserverIo\Psr\Servlet\Http; |
|
22
|
|
|
|
|
23
|
|
|
use AppserverIo\Psr\Servlet\ServletSessionWrapper; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* A wrapper to simplify session handling. |
|
27
|
|
|
* |
|
28
|
|
|
* @author Tim Wagner <[email protected]> |
|
29
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
|
30
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
31
|
|
|
* @link https://github.com/appserver-io-psr/servlet |
|
32
|
|
|
* @link http://www.appserver.io |
|
33
|
|
|
*/ |
|
34
|
|
|
class HttpSessionWrapper extends ServletSessionWrapper implements HttpSessionInterface |
|
35
|
|
|
{ |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Injects the passed HTTP session instance into this servlet session wrapper. |
|
39
|
|
|
* |
|
40
|
|
|
* @param \AppserverIo\Psr\Servlet\Http\HttpSessionInterface $session The session instance used for initialization |
|
41
|
|
|
* |
|
42
|
|
|
* @return void |
|
43
|
|
|
*/ |
|
44
|
|
|
public function injectHttpSession(HttpSessionInterface $session) |
|
45
|
|
|
{ |
|
46
|
|
|
$this->injectSession($session); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Returns the servlet session instance. |
|
51
|
|
|
* |
|
52
|
|
|
* @return \AppserverIo\Psr\Servlet\Http\HttpSessionInterface The session instance |
|
53
|
|
|
*/ |
|
54
|
|
|
public function getSession() |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->session; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Generates and propagates a new session ID and transfers all existing data |
|
61
|
|
|
* to the new session. |
|
62
|
|
|
* |
|
63
|
|
|
* @return string The new session ID |
|
64
|
|
|
* @throws \AppserverIo\Psr\Servlet\IllegalStateException |
|
65
|
|
|
*/ |
|
66
|
|
|
public function renewId() |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->getSession()->renewId(); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Shuts down this session |
|
73
|
|
|
* |
|
74
|
|
|
* This method must not be called manually – it is invoked by Flow's object |
|
75
|
|
|
* management. |
|
76
|
|
|
* |
|
77
|
|
|
* @return void |
|
78
|
|
|
*/ |
|
79
|
|
|
public function shutdownObject() |
|
80
|
|
|
{ |
|
81
|
|
|
$this->getSession()->shutdownObject(); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Explicitly writes and closes the session |
|
86
|
|
|
* |
|
87
|
|
|
* @return void |
|
88
|
|
|
*/ |
|
89
|
|
|
public function close() |
|
90
|
|
|
{ |
|
91
|
|
|
$this->getSession()->close(); |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|