Sessions are resetting on page refresh

qlithe

Supreme Member
Joined
Feb 14, 2012
Messages
1,252
Reaction score
288
So I have a login system (php/mysql) that's been working fine.

Yesterday I upgraded to a VPS and for some reason the sessions reset (people gets immediately logged out) after logging in and just loading another page

Anyone got a clue? All PHP settings seem right
 
Without seeing the code, I'm assuming that nothing has been changed since the server migration. There's bound to be an error or warning available (If not, you should enable error reporting using

PHP:
error_reporting(E_ALL);
ini_set('display_errors',1);


Then check to see if you're getting any kind of errors or warnings, a common one after host migration is this one:

PHP:
Warning: session_start(): Cannot send session cookie - headers already sent
 
It may be caused by some PHP plugin / addon that you have installed on VPS.
 
Have you checked if your session data is being stored at all or if it's just the login part that's malfunctioning? If you just installed a regular LAMP stack and used default settings there is no way that it could cause the issue you described.
 
check in php.ini:
http://php.net/manual/en/session.configuration.php

try to add this header:
header('Access-Control-Allow-Credentials: true');
if you use client js app like Angular check if you send this header:
Access-Control-Allow-Credentials: true
 
and check if you start a session:
session_start();

check if cookies is works... becouse session_id stored in cookie
 
Back
Top