Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class SASSET_Session_database_driver extends CI_Session_database_driver
- {
- /**
- * Session Write
- *
- * Execute the regular write(), then execute account_session_assoc(), which will see if
- * this session already has an existing record in the account_sessions_assoc association
- * table, if it does, just update the session_id, and +1 the regens value, if there is
- * no existing record, then isnert one.
- *
- * @param string $session_id Current session ID of the viewer
- * @param string $session_data Base64encoded session data
- *
- * @return boolean
- * @access public
- * @since 0.1.0
- */
- public function write( $session_id, $session_data )
- {
- // If the Accounts model isnt loaded, load it
- if( ! class_exists( 'Accounts_model', FALSE ) )
- {
- $CI =& get_instance();
- $CI->load->model( 'Accounts_model' );
- }
- if( ! parent::write( $session_id, $session_data ) )
- {
- log_message( "error", "SESSION " . __METHOD__ . " - FAILED to write session data for session ID $session_id" );
- return FALSE;
- }
- log_message( "error", "SESSION " . __METHOD__ . " - SUCCESSFULLY wrote session data for session ID $session_id" );
- // If theres an account ID set in the session data...
- if( isset( $_SESSION['account_id'] ) )
- {
- log_message( 'error', "SESSION " . __METHOD__ . " - Associating session $session_id to account ID " . $_SESSION['account_id'] );
- //log_message('error',"SESSION Writing session for account ID " . $_SESSION['account_id']);
- // ... Associate the account ID to the session ID
- //Accounts_model::$instance->assoc_session($_SESSION['account_id'], $session_id);
- Accounts_model::account_session_assoc();
- }
- else
- {
- //log_message('error',"SESSION Writing session, but NO ACCOUNT ID FOUND");
- }
- return TRUE;
- }
- /**
- * Garbage Collector
- *
- * Execute the regular gc(), then execute _assoc_gc(), which will delete any sessions from the
- * aaccount_sessions_assoc association table if the session_id isnt found in ci_sessions
- *
- * @param integer $maxlifetime Time stamp used to mark which sessions should be deleted
- *
- * @return boolean
- * @access public
- * @since 0.1.0
- */
- public function gc( $maxlifetime )
- {
- if( ! parent::gc( $maxlifetime ) )
- {
- log_message( 'error', "SESSION " . __METHOD__ . " - Garbage collector failed.." );
- return FALSE;
- }
- log_message( 'error', "SESSION " . __METHOD__ . " - Executing assoc GC" );
- return $this->_assoc_gc();
- }
- /**
- * Session Destroy
- *
- * Execute the regular destroy(), then execute _assoc_gc(), which will delete any sessions from the
- * account_sessions_assoc association table if the session_id isnt found in ci_sessions
- *
- * @param string $session_id Session ID to destroy
- *
- * @return boolean
- * @access public
- * @since 0.1.0
- */
- public function destroy( $session_id )
- {
- if( ! parent::destroy( $session_id ) )
- {
- log_message( 'error', "SESSION " . __METHOD__ . " - Delete failed for session ID $session_id" );
- return FALSE;
- }
- log_message( 'error', "SESSION " . __METHOD__ . " - Executing assoc GC" );
- return $this->_assoc_gc();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement