ellandrd
asked on
SESSIONS
at the top of my page i have this:
<?php
session_register();
if($_SESSION['username'] == '')
{
$_SESSION['username'] = trim($_GET['username']);
header("Location:http://192.168.0.2:7810");
}
?>
what im trying to do is when the page loads, check if $_SESSION['username'] has been registered. if YES just show the page else register the session and refresh the page...
but it isnt working... no errors BTW!
<?php
session_register();
if($_SESSION['username'] == '')
{
$_SESSION['username'] = trim($_GET['username']);
header("Location:http://192.168.0.2:7810");
}
?>
what im trying to do is when the page loads, check if $_SESSION['username'] has been registered. if YES just show the page else register the session and refresh the page...
but it isnt working... no errors BTW!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
see if i remove the header and not redirect it works fine, but since im using GET user can change username value in address so i need to redirect after session is set...
any idea's
any idea's
After doing a little Googling this seems to be a common problem.
try using
header('Location:http://192.168.0.2::7810/index.php?' . sid);
try using
header('Location:http://192.168.0.2::7810/index.php?' . sid);
ASKER
what is sid?
I'm assuming it's session id. It was posted in serveral places as a solution, but I find it odd that it's not treated as a varible. Give it a try if it doesn't work there might be another way.
ASKER
im trying this to test ....
<?php
session_start();
if(isset($_SESSION["userna
{
echo "already set<br><br>";
echo $_SESSION['username'];
}
else
{
$username = trim($_GET['username']);
$_SESSION['username'] = $username;
header('Location:http://192.168.0.2:7810/index.php');
}
?>