Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
webbasics
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
webbasics
Commits
3e255e54
Commit
3e255e54
authored
Oct 06, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Session::destroy() now also removes session data from cookie
parent
5614a4de
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
11 deletions
+15
-11
session.php
session.php
+14
-2
tests/test_session.php
tests/test_session.php
+1
-9
No files found.
session.php
View file @
3e255e54
...
@@ -92,11 +92,23 @@ class Session implements Singleton {
...
@@ -92,11 +92,23 @@ class Session implements Singleton {
$_SESSION
=
array
();
$_SESSION
=
array
();
}
}
function
destroy
(
$clear
=
false
)
{
function
destroy
(
$clear
=
true
)
{
// Delete session
session_destroy
();
// Clear session variables
if
(
$clear
)
if
(
$clear
)
$this
->
clear
();
$this
->
clear
();
session_destroy
();
// Delete session cookie
if
(
ini_get
(
'session.use_cookies'
))
{
$params
=
session_get_cookie_params
();
setcookie
(
session_name
(),
''
,
time
()
-
42000
,
$params
[
'path'
],
$params
[
'domain'
],
$params
[
'secure'
],
$params
[
'httponly'
]);
}
// Delete reference to instance so that the next getInstance() call
// will start a new session
self
::
$instance
=
null
;
self
::
$instance
=
null
;
}
}
}
}
...
...
tests/test_session.php
View file @
3e255e54
...
@@ -72,9 +72,6 @@ class SessionTest extends SingletonTestCase {
...
@@ -72,9 +72,6 @@ class SessionTest extends SingletonTestCase {
$old_id
=
session_id
();
$old_id
=
session_id
();
$this
->
session
->
regenerateId
();
$this
->
session
->
regenerateId
();
$this
->
assertNotEquals
(
$old_id
,
session_id
());
$this
->
assertNotEquals
(
$old_id
,
session_id
());
// Disable output buffering to show progress on other tests
@
ob_end_flush
();
}
}
function
testClear
()
{
function
testClear
()
{
...
@@ -83,17 +80,12 @@ class SessionTest extends SingletonTestCase {
...
@@ -83,17 +80,12 @@ class SessionTest extends SingletonTestCase {
$this
->
assertEmpty
(
$_SESSION
);
$this
->
assertEmpty
(
$_SESSION
);
}
}
function
testDestroySimple
()
{
$this
->
session
->
destroy
();
$this
->
assertEquals
(
''
,
session_id
());
}
/**
/**
* @depends testClear
* @depends testClear
*/
*/
function
testDestroyClear
()
{
function
testDestroyClear
()
{
$_SESSION
[
'foo'
]
=
'bar'
;
$_SESSION
[
'foo'
]
=
'bar'
;
$this
->
session
->
destroy
(
true
);
$this
->
session
->
destroy
();
$this
->
assertEmpty
(
$_SESSION
);
$this
->
assertEmpty
(
$_SESSION
);
$this
->
assertEquals
(
''
,
session_id
());
$this
->
assertEquals
(
''
,
session_id
());
}
}
...
...
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