Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
webbasics
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
webbasics
Commits
3e255e54
Commit
3e255e54
authored
12 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Session::destroy() now also removes session data from cookie
parent
5614a4de
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
session.php
+14
-2
14 additions, 2 deletions
session.php
tests/test_session.php
+1
-9
1 addition, 9 deletions
tests/test_session.php
with
15 additions
and
11 deletions
session.php
+
14
−
2
View file @
3e255e54
...
...
@@ -92,11 +92,23 @@ class Session implements Singleton {
$_SESSION
=
array
();
}
function
destroy
(
$clear
=
false
)
{
function
destroy
(
$clear
=
true
)
{
// Delete session
session_destroy
();
// Clear session variables
if
(
$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
;
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/test_session.php
+
1
−
9
View file @
3e255e54
...
...
@@ -72,9 +72,6 @@ class SessionTest extends SingletonTestCase {
$old_id
=
session_id
();
$this
->
session
->
regenerateId
();
$this
->
assertNotEquals
(
$old_id
,
session_id
());
// Disable output buffering to show progress on other tests
@
ob_end_flush
();
}
function
testClear
()
{
...
...
@@ -83,17 +80,12 @@ class SessionTest extends SingletonTestCase {
$this
->
assertEmpty
(
$_SESSION
);
}
function
testDestroySimple
()
{
$this
->
session
->
destroy
();
$this
->
assertEquals
(
''
,
session_id
());
}
/**
* @depends testClear
*/
function
testDestroyClear
()
{
$_SESSION
[
'foo'
]
=
'bar'
;
$this
->
session
->
destroy
(
true
);
$this
->
session
->
destroy
();
$this
->
assertEmpty
(
$_SESSION
);
$this
->
assertEquals
(
''
,
session_id
());
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment