Jump to content

[SOLVED] stylesheet and cookiecheck


prime

Recommended Posts

Sorry to bother the good people of this forum yet again

 

but I have been working on a stylesheet switcher program, and I have added a cookie detection check to it

 

<?php
   /* ------------------------------------------------------------------------------------------------------ */
  /* --------------------------| CHECK IF BROWSER CAN SUPPORT COOKIES |------------------------------------ */
/* ------------------------------------------------------------------------------------------------------ */
if (isset($_COOKIE['cookiecheck'])){
$prevpage = $_COOKIE["prevpage"];
setcookie ("prevpage", "$prevpage", time(), "/", "duelindeals.com", "0");
setcookie ("cookiecheck", "$confirmed", time(), "/", "duelindeals.com", "0");
$prevpage = urldecode("$prevpage");
$prevpage = unserialize("$prevpage");
header("Location:$prevpage");
}elseif (empty($_COOKIE['cookiecheck']) AND ($_GET["check"] == "yes")){
echo "your browser does not support cookies, you must have cookies enabled to use this feature";
exit();
}


   /* ------------------------------------------------------------------------------------------------------ */
  /* -------------------------------| INITIAL RECIEVING FILE |--------------------------------------------- */
/* ------------------------------------------------------------------------------------------------------ */
if (isset($_GET['stylesheet'])){
$stylesheet = $_GET['stylesheet'];
$prevpage = $_SERVER['HTTP_REFERER'];
$confirmed = "confirmed";
$prevpage = serialize("$prevpage");
$prevpage = urlencode("$prevpage");
setcookie ("cookiecheck", "$confirmed", time()+3000, "/", "duelindeals.com", "0");
setcookie ("prevpage", "$prevpage", time()+60, "/", "duelindeals.com", "0");
setcookie ("stylesheet", "$stylesheet", time()+9000, "/", "duelindeals.com", "0");
header("Location: $thisfile?check=yes");
}else{
header("Location:http://www.duelindeals.com");
}
?>

 

Anyhow the script is working great except for one tiny little problem it's not referring back to the sending page after the script finishes proper execution, it's going back to the home page.

 

what am i doing wrong, I tried echoing it out on the page to see what value $prevpage had and it seemed correct to the very page, but when its redirecting through the header it doesn't go there

 

thx in advance

Link to comment
Share on other sites

the only problem is in the 1st step (the second block of code) I get the http_referrer and assign it to the $prev variable which i then serialize and url encode, then enter into a cookie

 

the second step (first block of code) then retrieves that cookie, serializes and urldecodes and then assigns it to a variable then sets the cookie to delete and assigns that variable to the header for a redirect to the http referrer.

 

the only problem is its not actually going to the http referrer just to the domain

Link to comment
Share on other sites

Ok I found the problem

 

thank you anyhow everyone

 

for reference I was forgetting to place a simple exit in the first block of code right

 

<?php
   /* ------------------------------------------------------------------------------------------------------ */
  /* --------------------------| CHECK IF BROWSER CAN SUPPORT COOKIES |------------------------------------ */
/* ------------------------------------------------------------------------------------------------------ */
if (isset($_COOKIE['cookiecheck'])){
$prevpage = $_COOKIE["prevpage"];
setcookie ("prevpage", "$prevpage", time(), "/", "duelindeals.com", "0");
setcookie ("cookiecheck", "$confirmed", time(), "/", "duelindeals.com", "0");
$prevpage = urldecode("$prevpage");
$prevpage = unserialize("$prevpage");
header("Location:$prevpage");
exit(); // THIS IS WHERE i FORGOT THE EXIT
}elseif (empty($_COOKIE['cookiecheck']) AND ($_GET["check"] == "yes")){
echo "your browser does not support cookies, you must have cookies enabled to use this feature";
exit();
}


   /* ------------------------------------------------------------------------------------------------------ */
  /* -------------------------------| INITIAL RECIEVING FILE |--------------------------------------------- */
/* ------------------------------------------------------------------------------------------------------ */
if (isset($_GET['stylesheet'])){
$stylesheet = $_GET['stylesheet'];
$prevpage = $_SERVER['HTTP_REFERER'];
$confirmed = "confirmed";
$prevpage = serialize("$prevpage");
$prevpage = urlencode("$prevpage");
setcookie ("cookiecheck", "$confirmed", time()+3000, "/", "duelindeals.com", "0");
setcookie ("prevpage", "$prevpage", time()+60, "/", "duelindeals.com", "0");
setcookie ("stylesheet", "$stylesheet", time()+9000, "/", "duelindeals.com", "0");
header("Location: $thisfile?check=yes");
}else{
header("Location:http://www.duelindeals.com");
}
?>

 

So now the script is working 100% thx for your help anyhow

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.