Reputation: 43
I successfully create session and it works for all pages but when the following page is executed it does not display any session variable and asks for login again ..
here is the code:
if(!session_id())
session_start();
$con = mysql_connect("0.0.0.0 ","db_name","pwd");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db_name", $con);
if($_GET['rating']=='like')
{
$rcount = $_GET['rcount'] + 1;
$id= $_GET['id'];
mysql_query("UPDATE networx_notes SET up='$rcount' WHERE id='$id' ");
header( 'Location: http://adrress.com/somewhere.php' ) ;
}
Upvotes: 1
Views: 744
Reputation: 3500
If your session variables are not showing after the redirect http://adrress.com/somewhere.php
, possibilities:
session_start()
before trying to access session variables on this page http://adrress.com/somewhere.php.print_r($_SESSION)
before the redirect.Note: You should always die
\ exit
after a header location change.
Upvotes: 2