OpenCart – Extending your Session

Sometimes you will want to extend the default session expiration time in order to allow your customers to stay logged in. There is another article I wrote that deals with this same issue but I wanted to add two fixes that were probably a little more reliable in the long run. I recently found need to adjust the default variable in the php configuration because I was running a script that at times took 4 hours to complete. Without being logged in, the customer could not see a SUCCESS notification because the notification depended on a function called isLogged(), which checks to see if a session is in place. There are two ways to achieve a longer session.

METHOD ONE

In your opencart installation folder you will find a file called php.ini. Open it up in notepad. When opened you will see the following lines:

magic_quotes_gpc = Off;
register_globals = Off;
default_charset	= UTF-8;
memory_limit = 64M;
max_execution_time = 36000;
upload_max_filesize = 999M;
safe_mode = Off;
mysql.connect_timeout = 20;
session.use_cookies = On;
session.use_trans_sid = Off;
session.gc_maxlifetime = 172800;
allow_url_fopen = on;
;display_errors = 1;
;error_reporting = E_ALL;

The line that you want to change is “session.gc_maxlifetime = 172800;”

Just change it to something larger than what is already there.

METHOD TWO

If you are not using a custom php.ini file and you have access to WHM then you will be able to adjust the main php.ini at the root level.

1) Login to WHM Panel. It’s easy to access via cPanel

screen1.fw

2) Once there, type php in the search bar and you will see PHP Configuration Editor. Click on that and then choose ADVANCED MODE:

2.fw

Now you will want to scroll down until you find the value. Change it then save the php.ini

3.fw

Looking for quality OpenCart Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , | Posted under OpenCart | RSS 2.0

Author Spotlight

Joe Stenhouse

I am a web application developer that specializes in PHP, JAVASCRIPT, MYSQL, HTML, and CSS. We manifest exciting potentials within the world wide web through means of innovation.

Leave a Reply

Your email address will not be published. Required fields are marked *