Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
32f38320
Commit
32f38320
authored
Aug 03, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restructured session driver interfaces and added cookie session driver.
parent
3583bc3b
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
76 additions
and
35 deletions
+76
-35
session.php
application/config/session.php
+1
-1
session.php
system/session.php
+6
-2
apc.php
system/session/apc.php
+0
-11
cookie.php
system/session/cookie.php
+54
-0
db.php
system/session/db.php
+1
-1
driver.php
system/session/driver.php
+0
-8
file.php
system/session/file.php
+1
-1
memcached.php
system/session/memcached.php
+0
-11
sweeper.php
system/session/sweeper.php
+13
-0
No files found.
application/config/session.php
View file @
32f38320
...
@@ -12,7 +12,7 @@ return array(
...
@@ -12,7 +12,7 @@ return array(
| Since HTTP is stateless, sessions are used to maintain "state" across
| Since HTTP is stateless, sessions are used to maintain "state" across
| multiple requests from the same user of your application.
| multiple requests from the same user of your application.
|
|
| Supported Drivers: 'file', 'db', 'memcached', 'apc'.
| Supported Drivers: '
cookie', '
file', 'db', 'memcached', 'apc'.
|
|
*/
*/
...
...
system/session.php
View file @
32f38320
...
@@ -27,6 +27,10 @@ class Session {
...
@@ -27,6 +27,10 @@ class Session {
{
{
switch
(
Config
::
get
(
'session.driver'
))
switch
(
Config
::
get
(
'session.driver'
))
{
{
case
'cookie'
:
static
::
$driver
=
new
Session\Cookie
;
break
;
case
'file'
:
case
'file'
:
static
::
$driver
=
new
Session\File
;
static
::
$driver
=
new
Session\File
;
break
;
break
;
...
@@ -203,8 +207,8 @@ class Session {
...
@@ -203,8 +207,8 @@ class Session {
Cookie
::
put
(
'laravel_session'
,
static
::
$session
[
'id'
],
$minutes
,
$config
[
'path'
],
$config
[
'domain'
],
$config
[
'https'
],
$config
[
'http_only'
]);
Cookie
::
put
(
'laravel_session'
,
static
::
$session
[
'id'
],
$minutes
,
$config
[
'path'
],
$config
[
'domain'
],
$config
[
'https'
],
$config
[
'http_only'
]);
}
}
// 2% chance of performing session garbage collection...
// 2% chance of performing session garbage collection
on any given request
...
if
(
mt_rand
(
1
,
100
)
<=
2
)
if
(
mt_rand
(
1
,
100
)
<=
2
and
static
::
driver
()
instanceof
Session\Sweeper
)
{
{
static
::
driver
()
->
sweep
(
time
()
-
(
$config
[
'lifetime'
]
*
60
));
static
::
driver
()
->
sweep
(
time
()
-
(
$config
[
'lifetime'
]
*
60
));
}
}
...
...
system/session/apc.php
View file @
32f38320
...
@@ -37,15 +37,4 @@ class APC implements Driver {
...
@@ -37,15 +37,4 @@ class APC implements Driver {
Cache
::
driver
(
'apc'
)
->
forget
(
$id
);
Cache
::
driver
(
'apc'
)
->
forget
(
$id
);
}
}
/**
* Delete all expired sessions.
*
* @param int $expiration
* @return void
*/
public
function
sweep
(
$expiration
)
{
// APC sessions will expire automatically.
}
}
}
\ No newline at end of file
system/session/cookie.php
0 → 100644
View file @
32f38320
<?php
namespace
System\Session
;
use
System\Crypt
;
use
System\Config
;
class
Cookie
implements
Driver
{
public
function
__construct
()
{
if
(
Config
::
get
(
'application.key'
)
==
''
)
{
throw
new
\Exception
(
"You must set an application key before using the Cookie session driver."
);
}
}
/**
* Load a session by ID.
*
* @param string $id
* @return array
*/
public
function
load
(
$id
)
{
if
(
\System\Cookie
::
has
(
'session_payload'
))
{
return
unserialize
(
Crypt
::
decrypt
(
\System\Cookie
::
get
(
'session_payload'
)));
}
}
/**
* Save a session.
*
* @param array $session
* @return void
*/
public
function
save
(
$session
)
{
$c
=
\System\Config
::
get
(
'session'
);
\System\Cookie
::
put
(
'session_payload'
,
Crypt
::
encrypt
(
serialize
(
$session
)),
$c
[
'lifetime'
],
$c
[
'path'
],
$c
[
'domain'
],
$c
[
'https'
],
$c
[
'http_only'
]);
}
/**
* Delete a session by ID.
*
* @param string $id
* @return void
*/
public
function
delete
(
$id
)
{
\System\Cookie
::
forget
(
'session_payload'
);
}
}
\ No newline at end of file
system/session/db.php
View file @
32f38320
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
use
System\Config
;
use
System\Config
;
use
System\DB\Manager
;
use
System\DB\Manager
;
class
DB
implements
Driver
{
class
DB
implements
Driver
,
Sweeper
{
/**
/**
* Load a session by ID.
* Load a session by ID.
...
...
system/session/driver.php
View file @
32f38320
...
@@ -26,12 +26,4 @@ interface Driver {
...
@@ -26,12 +26,4 @@ interface Driver {
*/
*/
public
function
delete
(
$id
);
public
function
delete
(
$id
);
/**
* Delete all expired sessions.
*
* @param int $expiration
* @return void
*/
public
function
sweep
(
$expiration
);
}
}
\ No newline at end of file
system/session/file.php
View file @
32f38320
<?php
namespace
System\Session
;
<?php
namespace
System\Session
;
class
File
implements
Driver
{
class
File
implements
Driver
,
Sweeper
{
/**
/**
* Load a session by ID.
* Load a session by ID.
...
...
system/session/memcached.php
View file @
32f38320
...
@@ -38,15 +38,4 @@ class Memcached implements Driver {
...
@@ -38,15 +38,4 @@ class Memcached implements Driver {
Cache
::
driver
(
'memcached'
)
->
forget
(
$id
);
Cache
::
driver
(
'memcached'
)
->
forget
(
$id
);
}
}
/**
* Delete all expired sessions.
*
* @param int $expiration
* @return void
*/
public
function
sweep
(
$expiration
)
{
// Memcached sessions will expire automatically.
}
}
}
\ No newline at end of file
system/session/sweeper.php
0 → 100644
View file @
32f38320
<?php
namespace
System\Session
;
interface
Sweeper
{
/**
* Delete all expired sessions.
*
* @param int $expiration
* @return void
*/
public
function
sweep
(
$expiration
);
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment