Skip to content
This repository was archived by the owner on Nov 18, 2025. It is now read-only.

Commit 04c4434

Browse files
committed
🐛 fix session issues
Signed-off-by: otengkwame <[email protected]>
1 parent 653be77 commit 04c4434

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

composer.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,5 @@
1616
"framework/"
1717
]
1818
},
19-
"exclude-from-classmap": [
20-
"framework/libraries/OldSessionWrapper.php"
21-
],
2219
"minimum-stability": "stable"
2320
}

framework/libraries/Session/CI_OldSessionWrapper.php renamed to framework/libraries/Session/OldSessionWrapper.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@
4646
* @subpackage Libraries
4747
* @category Sessions
4848
* @author Andrey Andreev
49+
* @author Developer Kwame
4950
* @link https://codeigniter.com/userguide3/libraries/sessions.html
5051
*/
51-
class CI_OldSessionWrapper implements SessionHandlerInterface
52+
class CI_SessionWrapper implements SessionHandlerInterface
5253
{
5354

5455
protected $driver;
@@ -58,32 +59,34 @@ public function __construct(CI_Session_driver_interface $driver)
5859
$this->driver = $driver;
5960
}
6061

61-
public function open($save_path, $name)
62+
public function open($save_path, $name): bool
6263
{
6364
return $this->driver->open($save_path, $name);
6465
}
6566

66-
public function close()
67+
public function close(): bool
6768
{
6869
return $this->driver->close();
6970
}
7071

72+
#[\ReturnTypeWillChange]
7173
public function read($id)
7274
{
7375
return $this->driver->read($id);
7476
}
7577

76-
public function write($id, $data)
78+
public function write($id, $data): bool
7779
{
7880
return $this->driver->write($id, $data);
7981
}
8082

81-
public function destroy($id)
83+
public function destroy($id): bool
8284
{
8385
return $this->driver->destroy($id);
8486
}
8587

86-
public function gc($maxlifetime)
88+
#[\ReturnTypeWillChange]
89+
public function gc($maxlifetime): mixed
8790
{
8891
return $this->driver->gc($maxlifetime);
8992
}

framework/libraries/Session/PHP8SessionWrapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
* @author Andrey Andreev
4949
* @link https://codeigniter.com/userguide3/libraries/sessions.html
5050
*/
51-
class CI_SessionWrapper implements SessionHandlerInterface
51+
class CI_PHP8SessionWrapper implements SessionHandlerInterface
5252
{
5353

5454
protected CI_Session_driver_interface $driver;

framework/libraries/Session/Session.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,13 @@ public function __construct(array $params = [])
9898
$this->_config['_sid_regexp'] = $this->_sid_regexp;
9999

100100
$class = new $class($this->_config);
101+
101102
$wrapper = new CI_SessionWrapper($class);
103+
104+
if (is_php('8.0')) {
105+
$wrapper = new CI_PHP8SessionWrapper($class);
106+
}
107+
102108
if (is_php('5.4')) {
103109
session_set_save_handler($wrapper, true);
104110
} else {

0 commit comments

Comments
 (0)