XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
SessionCallback.class.php
1<?php
10
11if (!defined('XOOPS_ROOT_PATH')) {
12 exit();
13}
14
15// Registers session_write_close() to execute during the shutdown procedure.
16// This ensures session data is properly saved when PHP execution ends,
17// especially in environments where objects might be destroyed prematurely
18// (e.g., when using APC, memcached, etc.).
19function xclCallback($buffer)
20{
21 if (session_id()) {
22 session_write_close();
23 }
24 return $buffer;
25}
26
27ob_start('xclCallback');
28
30{
31 public function preBlockFilter()
32 {
33 $this->mRoot->mDelegateManager->add('XCube_Session.SetupSessionHandler', 'Legacy_SessionCallback::setupSessionHandler');
34 $this->mRoot->mDelegateManager->add('XCube_Session.GetSessionCookiePath', 'Legacy_SessionCallback::getSessionCookiePath');
35 }
36
37 public static function setupSessionHandler()
38 {
39 // Keep reference for compatibility with XCube architecture
40 $sessionHandler =& xoops_gethandler('session');
41 session_set_save_handler(
42 [&$sessionHandler, 'open'],
43 [&$sessionHandler, 'close'],
44 [&$sessionHandler, 'read'],
45 [&$sessionHandler, 'write'],
46 [&$sessionHandler, 'destroy'],
47 [&$sessionHandler, 'gc']
48 );
49 }
50
51 public static function getSessionCookiePath(&$cookiePath)
52 {
53 $parse_array = parse_url(XOOPS_URL);
54 $cookiePath = isset($parse_array['path']) ? $parse_array['path'] : '';
55 $cookiePath .= '/';
56 }
57}
preBlockFilter()
[Abstract] Executes the logic, when the controller executes preBlockFilter().