Skip to content

Commit 509b38a

Browse files
authored
Merge pull request #7503 from kenjis/fix-session-stop
fix: Session::stop() does not destroy session
2 parents 735b823 + 4baf5ab commit 509b38a

File tree

5 files changed

+42
-18
lines changed

5 files changed

+42
-18
lines changed

system/Session/Session.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -272,21 +272,13 @@ public function start()
272272
}
273273

274274
/**
275-
* Does a full stop of the session:
275+
* Destroys the current session.
276276
*
277-
* - destroys the session
278-
* - unsets the session id
279-
* - destroys the session cookie
277+
* @deprecated Use destroy() instead.
280278
*/
281279
public function stop()
282280
{
283-
setcookie(
284-
$this->sessionCookieName,
285-
session_id(),
286-
['expires' => 1, 'path' => $this->cookie->getPath(), 'domain' => $this->cookie->getDomain(), 'secure' => $this->cookie->isSecure(), 'httponly' => true]
287-
);
288-
289-
session_regenerate_id(true);
281+
$this->destroy();
290282
}
291283

292284
/**

user_guide_src/source/changelogs/v4.3.5.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ Release Date: Unreleased
99
:local:
1010
:depth: 3
1111

12+
SECURITY
13+
********
14+
15+
- Fixed that ``Session::stop()`` did not destroy the session.
16+
See :ref:`Session Library <session-stop>` for details.
17+
1218
BREAKING
1319
********
1420

@@ -21,6 +27,9 @@ Changes
2127
Deprecations
2228
************
2329

30+
- **Session:** The :ref:`Session::stop() <session-stop>` method is deprecated.
31+
Use the :ref:`Session::destroy() <session-destroy>` instead.
32+
2433
Bugs Fixed
2534
**********
2635

user_guide_src/source/installation/upgrade_435.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ Mandatory File Changes
1818
Breaking Changes
1919
****************
2020

21+
Session::stop()
22+
===============
23+
24+
Prior to v4.3.5, the ``Session::stop()`` method did not destroy the session due
25+
to a bug. This method has been modified to destroy the session, and now deprecated
26+
because it is exactly the same as the ``Session::destroy()`` method. So use the
27+
:ref:`Session::destroy <session-destroy>` method instead.
28+
29+
If you have code to depend on the bug, replace it with ``session_regenerate_id(true)``.
30+
31+
See also :ref:`Session Library <session-stop>`.
32+
2133
Breaking Enhancements
2234
*********************
2335

user_guide_src/source/libraries/sessions.rst

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,11 @@ intend to reuse that same key in the same request, you'd want to use
345345
Destroying a Session
346346
====================
347347

348+
.. _session-destroy:
349+
350+
destroy()
351+
---------
352+
348353
To clear the current session (for example, during a logout), you may
349354
simply use either PHP's `session_destroy() <https://www.php.net/session_destroy>`_
350355
function, or the library's ``destroy()`` method. Both will work in exactly the
@@ -357,11 +362,20 @@ same way:
357362
tempdata) will be destroyed permanently and functions will be
358363
unusable during the same request after you destroy the session.
359364

360-
You may also use the ``stop()`` method to completely kill the session
361-
by removing the old session ID, destroying all data, and destroying
362-
the cookie that contained the session ID:
365+
.. _session-stop:
366+
367+
stop()
368+
------
369+
370+
.. deprecated:: 4.3.5
371+
372+
The session class also has the ``stop()`` method.
373+
374+
.. warning:: Prior to v4.3.5, this method did not destroy the session due to a bug.
363375

364-
.. literalinclude:: sessions/038.php
376+
Starting with v4.3.5, this method has been modified to destroy the session.
377+
However, it is deprecated because it is exactly the same as the ``destroy()``
378+
method. Use the ``destroy()`` method instead.
365379

366380
Accessing Session Metadata
367381
==========================

user_guide_src/source/libraries/sessions/038.php

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)