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

Diff of /contributions/modules/session_expire/session_expire.module

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

revision 1.2, Thu Nov 27 16:46:00 2008 UTC revision 1.2.2.1, Wed Dec 3 15:55:23 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2    // $Id$
3    
4  // $Id: session_expire.module,v 1.1 2007/11/05 14:17:49 kbahey Exp $  /**
5     * @file
6  // Copyright 2007 Khalid Baheyeldin http://2bits.com   * Expires rows from the session table older than a certain time.
7     *
8     * @copyright Copyright 2007 Khalid Baheyeldin http://2bits.com
9     */
10    
11  define('SESSION_EXPIRE_INTERVAL', 'session_expire_interval');  define('SESSION_EXPIRE_INTERVAL', 'session_expire_interval');
12  define('SESSION_EXPIRE_AGE',      'session_expire_age');  define('SESSION_EXPIRE_AGE',      'session_expire_age');
13  define('SESSION_EXPIRE_MODE',     'session_expire_mode');  define('SESSION_EXPIRE_MODE',     'session_expire_mode');
14  define('SESSION_EXPIRE_LAST',     'session_expire_last');  define('SESSION_EXPIRE_LAST',     'session_expire_last');
15    
16    /**
17     * Implementation of hook_menu().
18     *
19     * @return array
20     */
21  function session_expire_menu() {  function session_expire_menu() {
22    $items = array();    $items['admin/settings/session_expire'] = array(
23          $items['admin/settings/session_expire'] = array(      'type'               => MENU_NORMAL_ITEM,
24                  'type'               => MENU_NORMAL_ITEM,      'title'              => 'Session expire',
25                  'title'              => t('Session expire'),      'description'        => 'Settings for session expiry',
26                  'description'        => t('Settings for session expiry'),      'page callback'      => 'drupal_get_form',
27                  'page callback'      => 'drupal_get_form',      'page arguments'     => array('session_expire_settings'),
28                  'page arguments'     => array('session_expire_settings'),      'access arguments'   => array('administer site configuration'),
29                  'access arguments'   => array('administer site configuration'),    );
         );  
30    return $items;    return $items;
31  }  }
32    
# Line 62  function session_expire_settings() { Line 70  function session_expire_settings() {
70    return system_settings_form($form);    return system_settings_form($form);
71  }  }
72    
73    /**
74     * Implementation of hook_cron().
75     */
76  function session_expire_cron() {  function session_expire_cron() {
77    // Check if it is the first time this hook fires    // Check if it is the first time this hook fires
78    $last_run_time = variable_get(SESSION_EXPIRE_LAST, 0);    $last_run_time = variable_get(SESSION_EXPIRE_LAST, 0);
# Line 75  function session_expire_cron() { Line 86  function session_expire_cron() {
86      $timestamp = time() - variable_get(SESSION_EXPIRE_AGE, 604800);      $timestamp = time() - variable_get(SESSION_EXPIRE_AGE, 604800);
87    
88      // Check if we should delete anonymous only or both anonymous and authenticated users      // Check if we should delete anonymous only or both anonymous and authenticated users
89        $extra_cond = '';
90      $mode = variable_get(SESSION_EXPIRE_MODE, 0);      $mode = variable_get(SESSION_EXPIRE_MODE, 0);
91      if (!$mode) {      if (!$mode) {
92        $extra_cond = 'AND uid = 0';        $extra_cond = 'AND uid = 0';

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

  ViewVC Help
Powered by ViewVC 1.1.2