Jump to content

Archived

This topic is now archived and is closed to further replies.

callenords

How do I control session lenght in OCS 2.3.4?

Recommended Posts

I have asked a similar question before with no replies, so I'm trying again: How do I control the length of my clients sessions in OSC 2.3.4?

 

I've just made a clean install and still sessions never seem to expire!

 

Tried editing php.ini "session.gc_maxlifetime" but it has no effect.

 

I would appreciate any input on this. Thanks.

Share this post


Link to post
Share on other sites

This is how I solved it for client sessions - not sure if it is the best way but it is working.

 

In includes/functions/sessions.php find this code:

    function _sess_read($key) {
      $value_query = tep_db_query("select value from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "'");
      $value = tep_db_fetch_array($value_query);

      if (isset($value['value'])) {
        return $value['value'];
      }

      return '';
    }

... and replace with this (update 3600 to your desired session length):

    function _sess_read($key) {
      $value_query = tep_db_query("select value, expiry from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "'");
      $value = tep_db_fetch_array($value_query);

      if (isset($value['value'])) { // A session was found
      
      $max_session_length = 3600; // Set how long a session should last in seconds (3600 = 60 min).
      $current_session_length = time() - $value['expiry']; // Calculate how long ago this session was last updated.

        if ($current_session_length < $max_session_length) { // If this session has not expired yet:
        return $value['value'];
        }
              
      }

      return '';
    }

Share this post


Link to post
Share on other sites

×