Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 67dd846

Browse files
committed
Merge branch 'hotfix/15'
Close #15
2 parents 6d55574 + a818909 commit 67dd846

File tree

7 files changed

+722
-0
lines changed

7 files changed

+722
-0
lines changed

doc/book/zend.session.config.md

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
# Session Config
2+
3+
Zend Framework comes with a standard set of config classes which are ready for you to use. Config
4+
handles setting various configuration such as where a cookie lives, lifetime, including several bits
5+
to configure ext/session when using `Zend\Session\Config\SessionConfig`.
6+
7+
orphan
8+
9+
## Standard Config
10+
11+
`Zend\Session\Config\StandardConfig` provides you a basic interface for implementing sessions when
12+
*not* leveraging ext/session. This is utilized more for specialized cases such as when you might
13+
have session management done by another system.
14+
15+
### Basic Configuration Options
16+
17+
The following configuration options are defined by `Zend\Session\Config\StandardConfig`.
18+
19+
<table>
20+
<colgroup>
21+
<col width="19%" />
22+
<col width="10%" />
23+
<col width="70%" />
24+
</colgroup>
25+
<thead>
26+
<tr class="header">
27+
<th align="left">Option</th>
28+
<th align="left">Data Type</th>
29+
<th align="left">Description</th>
30+
</tr>
31+
</thead>
32+
<tbody>
33+
<tr class="odd">
34+
<td align="left">cache_expire</td>
35+
<td align="left"><code>integer</code></td>
36+
<td align="left">Specifies time-to-live for cached session pages in minutes.</td>
37+
</tr>
38+
<tr class="even">
39+
<td align="left">cookie_domain</td>
40+
<td align="left"><code>string</code></td>
41+
<td align="left">Specifies the domain to set in the session cookie.</td>
42+
</tr>
43+
<tr class="odd">
44+
<td align="left">cookie_httponly</td>
45+
<td align="left"><code>boolean</code></td>
46+
<td align="left">Marks the cookie as accessible only through the HTTP protocol.</td>
47+
</tr>
48+
<tr class="even">
49+
<td align="left">cookie_lifetime</td>
50+
<td align="left"><code>integer</code></td>
51+
<td align="left">Specifies the lifetime of the cookie in seconds which is sent to the browser.</td>
52+
</tr>
53+
<tr class="odd">
54+
<td align="left">cookie_path</td>
55+
<td align="left"><code>string</code></td>
56+
<td align="left">Specifies path to set in the session cookie.</td>
57+
</tr>
58+
<tr class="even">
59+
<td align="left">cookie_secure</td>
60+
<td align="left"><code>boolean</code></td>
61+
<td align="left">Specifies whether cookies should only be sent over secure connections.</td>
62+
</tr>
63+
<tr class="odd">
64+
<td align="left">entropy_length</td>
65+
<td align="left"><code>integer</code></td>
66+
<td align="left">Specifies the number of bytes which will be read from the file specified in
67+
entropy_file.</td>
68+
</tr>
69+
<tr class="even">
70+
<td align="left">entropy_file</td>
71+
<td align="left"><code>string</code></td>
72+
<td align="left">Defines a path to an external resource (file) which will be used as an additional
73+
entropy.</td>
74+
</tr>
75+
<tr class="odd">
76+
<td align="left">gc_maxlifetime</td>
77+
<td align="left"><code>integer</code></td>
78+
<td align="left">Specifies the number of seconds after which data will be seen as 'garbage'.</td>
79+
</tr>
80+
<tr class="even">
81+
<td align="left">gc_divisor</td>
82+
<td align="left"><code>integer</code></td>
83+
<td align="left">Defines the probability that the gc process is started on every session
84+
initialization.</td>
85+
</tr>
86+
<tr class="odd">
87+
<td align="left">gc_probability</td>
88+
<td align="left"><code>integer</code></td>
89+
<td align="left">Defines the probability that the gc process is started on every session
90+
initialization.</td>
91+
</tr>
92+
<tr class="even">
93+
<td align="left">hash_bits_per_character</td>
94+
<td align="left"><code>integer</code></td>
95+
<td align="left">Defines how many bits are stored in each character when converting the binary hash
96+
data.</td>
97+
</tr>
98+
<tr class="odd">
99+
<td align="left">name</td>
100+
<td align="left"><code>string</code></td>
101+
<td align="left">Specifies the name of the session which is used as cookie name.</td>
102+
</tr>
103+
<tr class="even">
104+
<td align="left">remember_me_seconds</td>
105+
<td align="left"><code>integer</code></td>
106+
<td align="left">Specifies how long to remember the session before clearing data.</td>
107+
</tr>
108+
<tr class="odd">
109+
<td align="left">save_path</td>
110+
<td align="left"><code>string</code></td>
111+
<td align="left">Defines the argument which is passed to the save handler.</td>
112+
</tr>
113+
<tr class="even">
114+
<td align="left">use_cookies</td>
115+
<td align="left"><code>boolean</code></td>
116+
<td align="left">Specifies whether the module will use cookies to store the session id.</td>
117+
</tr>
118+
</tbody>
119+
</table>
120+
121+
### Basic Usage
122+
123+
A basic example is one like the following:
124+
125+
```php
126+
use Zend\Session\Config\StandardConfig;
127+
use Zend\Session\SessionManager;
128+
129+
$config = new StandardConfig();
130+
$config->setOptions(array(
131+
'remember_me_seconds' => 1800,
132+
'name' => 'zf2',
133+
));
134+
$manager = new SessionManager($config);
135+
```
136+
137+
orphan
138+
139+
## Session Config
140+
141+
`Zend\Session\Config\SessionConfig` provides you a basic interface for implementing sessions when
142+
that leverage PHP's ext/session. Most configuration options configure either the
143+
`Zend\Session\Storage` OR configure ext/session directly.
144+
145+
### Basic Configuration Options
146+
147+
The following configuration options are defined by `Zend\Session\Config\SessionConfig`, note that it
148+
inherits all configuration from `Zend\Session\Config\StandardConfig`.
149+
150+
<table>
151+
<colgroup>
152+
<col width="19%" />
153+
<col width="10%" />
154+
<col width="70%" />
155+
</colgroup>
156+
<thead>
157+
<tr class="header">
158+
<th align="left">Option</th>
159+
<th align="left">Data Type</th>
160+
<th align="left">Description</th>
161+
</tr>
162+
</thead>
163+
<tbody>
164+
<tr class="odd">
165+
<td align="left">cache_limiter</td>
166+
<td align="left"><code>string</code></td>
167+
<td align="left">Specifies the cache control method used for session pages.</td>
168+
</tr>
169+
<tr class="even">
170+
<td align="left">hash_function</td>
171+
<td align="left"><code>string</code></td>
172+
<td align="left">Allows you to specify the hash algorithm used to generate the session IDs.</td>
173+
</tr>
174+
<tr class="odd">
175+
<td align="left">php_save_handler</td>
176+
<td align="left"><code>string</code></td>
177+
<td align="left">Defines the name of a PHP save_handler embedded into PHP.</td>
178+
</tr>
179+
<tr class="even">
180+
<td align="left">serialize_handler</td>
181+
<td align="left"><code>string</code></td>
182+
<td align="left">Defines the name of the handler which is used to serialize/deserialize data.</td>
183+
</tr>
184+
<tr class="odd">
185+
<td align="left">url_rewriter_tags</td>
186+
<td align="left"><code>string</code></td>
187+
<td align="left">Specifies which HTML tags are rewritten to include session id if transparent sid
188+
enabled.</td>
189+
</tr>
190+
<tr class="even">
191+
<td align="left">use_trans_sid</td>
192+
<td align="left"><code>boolean</code></td>
193+
<td align="left">Whether transparent sid support is enabled or not.</td>
194+
</tr>
195+
</tbody>
196+
</table>
197+
198+
### Basic Usage
199+
200+
A basic example is one like the following:
201+
202+
```php
203+
use Zend\Session\Config\SessionConfig;
204+
use Zend\Session\SessionManager;
205+
206+
$config = new SessionConfig();
207+
$config->setOptions(array(
208+
'phpSaveHandler' => 'redis',
209+
'savePath' => 'tcp://127.0.0.1:6379?weight=1&timeout=1',
210+
));
211+
$manager = new SessionManager($config);
212+
```
213+
214+
### Service Manager Factory
215+
216+
`Zend\Session` ships with a Service Manager &lt;zend.service-manager.intro&gt; factory which reads
217+
configuration data from the application configuration and injects a corresponding instance of
218+
`Zend\Session\Config\SessionConfig` into the session manager automatically.
219+
220+
To use this factory, you first need to register it with the Service Manager by adding the
221+
appropriate factory definition:
222+
223+
```php
224+
'service_manager' => array(
225+
'factories' => array(
226+
'Zend\Session\Config\ConfigInterface' => 'Zend\Session\Service\SessionConfigFactory',
227+
),
228+
),
229+
```
230+
231+
Then place your application's session configuration in the root-level configuration key
232+
`session_config`:
233+
234+
```php
235+
'session_config' => array(
236+
'phpSaveHandler' => 'redis',
237+
'savePath' => 'tcp://127.0.0.1:6379?weight=1&timeout=1',
238+
),
239+
```
240+
241+
Any of the configuration options defined in zend.session.config.session-config.options can be used
242+
there, as well as the following factory-specific configuration options:
243+
244+
<table>
245+
<colgroup>
246+
<col width="19%" />
247+
<col width="10%" />
248+
<col width="70%" />
249+
</colgroup>
250+
<thead>
251+
<tr class="header">
252+
<th align="left">Option</th>
253+
<th align="left">Data Type</th>
254+
<th align="left">Description</th>
255+
</tr>
256+
</thead>
257+
<tbody>
258+
<tr class="odd">
259+
<td align="left">config_class</td>
260+
<td align="left"><code>string</code></td>
261+
<td align="left">Name of the class to use as the configuration container (Defaults to
262+
<code>Zend\Session\Config\SessionConfig</code></td>
263+
</tr>
264+
</tbody>
265+
</table>
266+
267+
## Custom Configuration
268+
269+
In the event that you prefer to create your own session configuration; you *must* implement
270+
`Zend\Session\Config\ConfigInterface` which contains the basic interface for items needed when
271+
implementing a session. This includes cookie configuration, lifetime, session name, save path and an
272+
interface for getting and setting options.

doc/book/zend.session.container.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Session Container
2+
3+
`Zend\Session\Container` instances provide the primary API for manipulating session data in the Zend
4+
Framework. Containers are used to segregate all session data, although a default namespace exists
5+
for those who only want one namespace for all their session data.
6+
7+
Each instance of `Zend\Session\Container` corresponds to an entry of the `Zend\Session\Storage`,
8+
where the namespace is used as the key. `Zend\Session\Container` itself is an instance of an
9+
ArrayObject.
10+
11+
## Basic Usage
12+
13+
```php
14+
use Zend\Session\Container;
15+
16+
$container = new Container('namespace');
17+
$container->item = 'foo';
18+
```
19+
20+
## Setting the Default Session Manager
21+
22+
In the event you are using multiple session managers or prefer to be explicit, the default session
23+
manager that is utilized can be explicitly set.
24+
25+
```php
26+
use Zend\Session\Container;
27+
use Zend\Session\SessionManager;
28+
29+
$manager = new SessionManager();
30+
Container::setDefaultManager($manager);
31+
```

0 commit comments

Comments
 (0)