I have a simple script which creates a variable and send it to another page within a session. Problem is the session variable does not get sent. I can print out variale on the page it was created on but not on another page. I'm using start session on both pages.
I'm using WAMP with php5.2 as a test server. Any ideas.
<?php // index.php
session_start();
header("Cache-control: private");
echo $_SESSION["username"];
if ($_SESSION["username"] == "") {
include 'includes/login_form.php';
}
?>
<?php // auth.php
session_start();
header("Cache-control: private");
$username = $_GET['username'];
$password = sha1($_GET['password']);
mysql_connect("localhost","root","");
mysql_select_db("testcms");
$auth = mysql_query("SELECT `username` , `password` , `usergroup`
FROM `users`
WHERE `username` = CONVERT( _utf8 '$username'
USING latin1 )
COLLATE latin1_swedish_ci
AND `password` = '$password'
COLLATE latin1_swedish_ci
LIMIT 0 , 1");
while($r=mysql_fetch_array($auth))
{
$_SESSION["username"] = $r[username];
$_SESSION["usergroup"] = $r[usergroup];
}
header("Refresh: 5; url=../index.php");
?>