Hi,
Could anyone tell me why my $_SESSION variables are not being carried over to my other PHP page that is called with ajax.
All pages have session_start();
It works on my local machine, but when I upload it to my server, it doesn't work, and on refresh it takes me back to the login screen...
EDIT:
The session variables saved once a user logs in
$_SESSION['user_id'] = $user_id;
$_SESSION['username'] = $user_email;
$_SESSION['name'] = $un;
$_SESSION['login_times'] = $login_time;
$_SESSION['profile_pic'] = $profile_pic;
And when the ajax script calls the other PHP:
session_start();
$user_id = $_GET['id'];
$newsfeed_id = $_GET['nf_id'];
$comment = $_GET['comment'];
$conn = mysql_connect('localhost', 'admin', 'root') or die(mysql_error());
mysql_select_db('main') or die(mysql_error());
// insert new comment
$query = "INSERT INTO newsfeed_comments ".
"VALUES ('', '{$_SESSION['user_id']}', '{$comment}', '{$newsfeed_id}')";
mysql_query($query) or die(mysql_error());
But nothing is returned in the response text, and the values of $_SESSION['username'] has been unset, and i get redirected back to the login.
Does anyone know what the problem is?
Thanks!