Mobile app version of vmapp.org
Login or Join
Ravi8258870

: Logged Out Too Soon; PHP Sessions Expire Too Quickly. Is this a Linux, CentOS, Cookies, CPanel problem? Recently, I've been getting logged out sooner than expected on several websites that I

@Ravi8258870

Posted in: #Cookie #Expires #Linux #Php #Session

Recently, I've been getting logged out sooner than expected on several websites that I manage on Linux servers. The problem started spontaneously a few months ago. At the time, I had not made any recent changes to the website code or the CPanel settings. There was no need to, because my CPanel settings always kept me logged in for about 18 hours. But now I'm getting logged out after just 30 minutes of inactivity. Here are the CPanel settings that worked reliably until a few months ago:

session.cookie_lifetime 0
session.gc_maxlifetime 65535


For troubleshooting, I've also tried the equivalent settings in the htaccess file:

php_value session.cookie_lifetime 0
php_value session.gc_maxlifetime 65535


(65535 seconds is equivalent to about 18 hours.)

I've tested this problem with three different PHP forms. First, I log in with a user name and password. If I then press F5 to refresh within 30 minutes, I am still logged in. But if I wait longer than 30 minutes before refreshing the page, I find that I have been logged out. Also, I've tried two different servers provided by the same web host, but the problem remains.

I'm on a shared CentOS server, and I don't have access to the php.ini file -- only the CPanel and .htaccess file.

I suspect this problem has been caused by a recent Linux / CentOS update, but I don't see similar complaints on the internet. So I wonder if it's just my web host. (They are otherwise very reliable.)

Has anyone encountered this problem? Is it a Linux / CentOS bug? Is there a fix? Or should I move to another web host?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Ravi8258870

1 Comments

Sorted by latest first Latest Oldest Best

 

@Si4351233

Thanks for the trouble-shooting help. I have solved the problem -- by specifying a custom folder for storing temporary session data. Here's how:


Locate the folder where your session data files are currently being stored. In my case, the folder was called tmp. The folder name and location may vary, depending on your version of Linux and how it has been set up, afaik.
Create a new folder, located in the same folder as the tmp folder (not within the tmp folder).
In cPanel (php version / PHP Selector | options), specify the full path to the new folder as the value for session.save_path. You can also do this in your php.ini file, if you have access to it.


If you need more information, the following links might be helpful:
security.stackexchange.com/questions/19053/where-and-how-is-data-stored-in-a-session stackoverflow.com/questions/4927850/location-for-session-files-in-apache-php docs.cloudlinux.com/index.html?tmp_directories.html (CloudLinux Documentation: Tmp Directories)

I hope this helps anyone who encounters the same problem in the future.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme