/[drupal]/contributions/modules/session_restore/session_restore.module
ViewVC logotype

Diff of /contributions/modules/session_restore/session_restore.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Wed Jul 11 08:17:19 2007 UTC revision 1.2, Thu Aug 2 19:13:47 2007 UTC
# Line 1  Line 1 
1  <?php  <?php
2  /* $Id$ */  /* $Id: session_restore.module,v 1.1 2007/07/11 08:17:19 karthik Exp $ */
3    
4  /**  /**
5   * @file   * @file
# Line 55  function session_restore_exit() { Line 55  function session_restore_exit() {
55   */   */
56  function _session_restore_vet($session) {  function _session_restore_vet($session) {
57    // Unset variables that might break this or other modules upon restore.    // Unset variables that might break this or other modules upon restore.
58    // session_limit: Session limit module needs this variable unset during log in    $variables = module_invoke_all('session_restore');
59      // session_limit: Session limit module needs this variable unset during login
60    // for it to work.    // for it to work.
61    unset($session['session_limit']);    $variables[] = 'session_limit';
62      // lastaccess: An autologout module variable.
63      $variables[] = 'lastaccess';
64    
65      foreach ($variables as $variable) {
66        unset($session[$variable]);
67      }
68    
69    return serialize($session);    return serialize($session);
70  }  }
# Line 76  function _session_restore_session_get($u Line 83  function _session_restore_session_get($u
83    $session = db_result(db_query("SELECT session FROM {session_restore} WHERE uid = %d", $uid));    $session = db_result(db_query("SELECT session FROM {session_restore} WHERE uid = %d", $uid));
84    $session = $session ? unserialize($session) : $_SESSION;    $session = $session ? unserialize($session) : $_SESSION;
85    
86    // TODO: Perhaps add configuration options to filter out certain    // Unset variables that might break this or other modules upon restore.
87    // variables upon restore.    // See _session_restore_vet for more information.
88      $variables = module_invoke_all('session_restore');
89      $variables[] = 'session_limit';
90      $variables[] = 'lastaccess';
91    
92      // Ensure that special variables (usually set during hook_user are not
93      // overwritten.
94      foreach ($variables as $variable) {
95        if (isset($_SESSION[$variable])) {
96          $session[$variable] = $_SESSION[$variable];
97        }
98      }
99    
100    return $session;    return $session;
101  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2