Timeout sessions solved... (Bugs)

by PeterSB @, Sunday, August 24, 2008, 21:32 (5721 days ago)
edited by PeterSB, Sunday, August 24, 2008, 21:49

Hello,

At last...! I have solved an old problem that I never found the solution here in the forum (ver.2 or ver.1) for the timeout session problem when posting or writing a post for a long period of time. As described here:
http://mylittleforum.net/forum/index.php?id=422

The problem solution depends on the web server where the forum is working and is related completly to the *tmp* dir where the PHP sessions are stored.

You can find a good explanation of the problem here...

In my case I had to change the php.ini where the script files are located (it depends on the server, some webhostings don't let you change the php.ini file)

When you login to the forum, the script start a PHP session for your local cookies in a temp dir on the server, beacause this dir is filled with hundreds of files per minute for all the users in that server, this dir has to be cleaned every "x" period of time, usually every 20 to 25 minutes. That's why if your posting writing took you more time than that, that will loose your login info and then logout automatically.

The solution is to change that subdir where the sessions files are stored to one of your local subdirs in the server. By this, no automatic process in the server will erase these files.

If you can add a php.ini file where your forum files are located, you have to add this in the php.ini

##-----php.ini----------------------
session.use_trans_sid=0;
session.gc_maxlifetime=180000;
session.cookie_lifetime=180000;
session.gc_probability=1;
session.gc_divisor=500;
session.save_path=/home/domain/public_html/phpsessions;
##-----php.ini----------------------


If you can not modify a php.ini file you can add some lines where the "session_start();" line is located like this:


##-----script--------------------
ini_set('session.use_trans_sid', 0);
ini_set('session.gc_maxlifetime', 180000);
ini_set('session.cookie_lifetime', 180000);
ini_set('session.gc_probability', 1);
ini_set('session.gc_divisor', 500);
ini_set('session.save_path', '/home/domain/public_html/phpsessions/');
##-----script--------------------

ver.1 --- inc.php
ver.2 --- index.php

You can see the value of the variable with this (for every variable one line):
echo 'session.gc_probability = ' .ini_get('session.gc_probability') . "<br>";

.
.
.
.
Hope this helps.
Peter

locked
5342 views

Complete thread:

 RSS Feed of thread