From d4b2aa3eed08d6989f7858040f85fd0c16562164 Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@osticket.com>
Date: Tue, 18 Feb 2014 17:47:04 +0000
Subject: [PATCH] Register session close on shutdown at the start of session
 handling

This is necessary to make sure session data is saved on redirect.
---
 include/class.ostsession.php | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/class.ostsession.php b/include/class.ostsession.php
index d27debae7..e588f6185 100644
--- a/include/class.ostsession.php
+++ b/include/class.ostsession.php
@@ -26,8 +26,12 @@ class osTicketSession {
         if(!$this->ttl)
             $this->ttl=SESSION_TTL;
 
+        // Set osTicket specific session name.
         session_name('OSTSESSID');
 
+        // Forced cleanup on shutdown
+        register_shutdown_function('session_write_close');
+
         if (OsticketConfig::getDBVersion())
             return session_start();
 
@@ -56,8 +60,6 @@ class osTicketSession {
             array(&$this, 'destroy'),
             array(&$this, 'gc')
         );
-        //Forced cleanup.
-        register_shutdown_function('session_write_close');
 
         //Start the session.
         session_start();
-- 
GitLab