User Tools

Site Tools


tutorials:zencartmods:sessions.html

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tutorials:zencartmods:sessions.html [2011/09/13 19:49]
daigo created
tutorials:zencartmods:sessions.html [2016/01/28 18:05]
Line 1: Line 1:
-===== Changing Session Length ===== 
- 
-By default, a zencart session will timeout after 24 minutes of inactivity. This will log someone out, or delete their temporary shopping cart if they weren'​t logged in. Depending on your shop you might want this to be longer or shorter. ​ 
- 
-Before we begin, make sure that the STORE_SESSIONS constant in **includes/​configure.php** is set to '​db'​ and not ''​. 
- 
-You should have this line: 
-<code php> 
-define('​STORE_SESSIONS',​ '​db'​);​ 
-</​code>​ 
- 
-If this is not set to '​db',​ then this mod will certainly not work. 
- 
-Ok, so to change the session length, find these lines in **includes/​functions/​sessions.php** 
- 
-<code php> 
-  if (STORE_SESSIONS == '​db'​) { 
-    if (defined('​DIR_WS_ADMIN'​)) { 
-      if (!$SESS_LIFE = (SESSION_TIMEOUT_ADMIN + 900)) { 
-        $SESS_LIFE = (SESSION_TIMEOUT_ADMIN + 900); 
-      } 
-    } else { 
-      if (!$SESS_LIFE = get_cfg_var('​session.gc_maxlifetime'​)) { 
-        $SESS_LIFE = 1440; 
-      } 
-    } 
-</​code>​ 
- 
-As you can probably tell, there are 2 ways we can go about this.  
- 
- 
-The first is to edit **php.ini** on your server and set **session.gc_maxlifetime** to a new value. ​ 
- 
-The other option, which you might prefer if you don't have access to your php.ini file, is to replace the above lines of code with  
- 
-<code php> 
-  if (STORE_SESSIONS == '​db'​) { 
-    if (defined('​DIR_WS_ADMIN'​)) { 
-      if (!$SESS_LIFE = (SESSION_TIMEOUT_ADMIN + 900)) { 
-        $SESS_LIFE = (SESSION_TIMEOUT_ADMIN + 900); 
-      } 
-    } else {                                                                                                                                                                                                        ​ 
-        $SESS_LIFE = 86400; ​                                                                                                                                                                                                                                                           ​ 
-    } 
-</​code>​ 
- 
-The $SESS_LIFE variable is stored in seconds, so 86400 = (24 * 60 * 60) = 1 day.  
- 
-For extra credit, you can even set the value to a db-stored variable for easy updating. ​ 
- 
-Note: It is very important not to do this mod if you are using filesystem-based sessions. While zencart manages db sessions, filesystem based sessions will get garbage-collected by php regardless of zencarts **$SESS_LIFE** variable. 
  
/home/ladyada/public_html/wiki/data/pages/tutorials/zencartmods/sessions.html.txt · Last modified: 2016/01/28 18:05 (external edit)