Page 1 of 1

Trouble baking a cookie with a redirect.

Posted: Sat Dec 02, 2006 1:24 pm
by ridshack
When a user gets redirected for not having yet logged in I want to pass the page they where trying to access so when correctly authenticate I can send them back to where they came, but I cant seem to set a cookie this cookie.

I really appreciate any guidance. Also if you think I should be doing this all different then please let me know what you suggest.

Page 1

Code: Select all

<?php
$value = "https://www.web.com/office/admin/queries.php";
setcookie("TestCookie", $value);

//Only Allows Authenticated users to access the page
$Techs = $_COOKIE["Techs"];
if(!isset($Techs)) {
$page = "https://www.web.com/office/admin/queries.php";
setcookie("page",$page);
}
?>
Try to display the cookie here and it appears not to be set. As it does not echo the cookie value.

Page 2

Code: Select all

<html>
<head>
<meta http-equiv="refresh" content="2; URL=https://www.web.com/office/DB_authenticate.php">
</head>
<body>
<?php
echo "You must first login.";
echo $_COOKIE["TestCookie"]; //This just to see if the cookie is working

?>

Posted: Sat Dec 02, 2006 2:18 pm
by feyd
Using a header level redirection can often short circuit any other header operations that may be in there for many browsers. It may be best to use sessions to transfer this information. You may need to include session_write_close() if you go that path as well.