@@ -213,7 +213,7 @@ public static function started() {
213
213
* @return boolean True if variable is there
214
214
*/
215
215
public static function check ($ name = null ) {
216
- if (!self ::started () && ! self :: start ()) {
216
+ if (!self ::start ()) {
217
217
return false ;
218
218
}
219
219
if (empty ($ name )) {
@@ -223,9 +223,17 @@ public static function check($name = null) {
223
223
}
224
224
225
225
/**
226
- * Returns the Session id
226
+ * Returns the session id.
227
+ * Calling this method will not auto start the session. You might have to manually
228
+ * assert a started session.
227
229
*
228
- * @param string $id
230
+ * Passing an id into it, you can also replace the session id if the session
231
+ * has not already been started.
232
+ * Note that depending on the session handler, not all characters are allowed
233
+ * within the session id. For example, the file session handler only allows
234
+ * characters in the range a-z A-Z 0-9 , (comma) and - (minus).
235
+ *
236
+ * @param string $id Id to replace the current session id
229
237
* @return string Session id
230
238
*/
231
239
public static function id ($ id = null ) {
@@ -254,7 +262,7 @@ public static function delete($name) {
254
262
}
255
263
256
264
/**
257
- * Used to write new data to _SESSION, since PHP doesn't like us setting the _SESSION var itself
265
+ * Used to write new data to _SESSION, since PHP doesn't like us setting the _SESSION var itself.
258
266
*
259
267
* @param array $old Set of old variables => values
260
268
* @param array $new New set of variable => value
@@ -333,10 +341,10 @@ protected static function _validAgentAndTime() {
333
341
}
334
342
335
343
/**
336
- * Get / Set the userAgent
344
+ * Get / Set the user agent
337
345
*
338
- * @param string $userAgent Set the userAgent
339
- * @return void
346
+ * @param string $userAgent Set the user agent
347
+ * @return string Current user agent
340
348
*/
341
349
public static function userAgent ($ userAgent = null ) {
342
350
if ($ userAgent ) {
@@ -355,7 +363,7 @@ public static function userAgent($userAgent = null) {
355
363
* @return mixed The value of the session variable
356
364
*/
357
365
public static function read ($ name = null ) {
358
- if (!self ::started () && ! self :: start ()) {
366
+ if (!self ::start ()) {
359
367
return false ;
360
368
}
361
369
if (is_null ($ name )) {
@@ -393,7 +401,7 @@ protected static function _returnSessionVars() {
393
401
* @return boolean True if the write was successful, false if the write failed
394
402
*/
395
403
public static function write ($ name , $ value = null ) {
396
- if (!self ::started () && ! self :: start ()) {
404
+ if (!self ::start ()) {
397
405
return false ;
398
406
}
399
407
if (empty ($ name )) {
@@ -418,9 +426,7 @@ public static function write($name, $value = null) {
418
426
* @return void
419
427
*/
420
428
public static function destroy () {
421
- if (!self ::started ()) {
422
- self ::start ();
423
- }
429
+ self ::start ();
424
430
session_destroy ();
425
431
self ::clear ();
426
432
}
@@ -620,7 +626,7 @@ protected static function _startSession() {
620
626
* @return void
621
627
*/
622
628
protected static function _checkValid () {
623
- if (!self ::started () && ! self :: start ()) {
629
+ if (!self ::start ()) {
624
630
self ::$ valid = false ;
625
631
return false ;
626
632
}
0 commit comments