Page 1 of 1

Hidding GET variable

Posted: Thu Feb 27, 2003 6:14 pm
by alsaffar
Hi there,

Im setting a cookie in a page and then refresh the page to test if the cookie was set or not and Im using a GET variable to acomplish my mission of testing if the cookie was set or not.

My script:

<?
if (!isset($HTTP_GET_VARS[C]))
{
setcookie("TestCookie", "Test");
Header("Location: $PHP_SELF?C=1");
}
else
{
if (isset($HTTP_COOKIE_VARS[TestCookie]))
{
echo "Cookie is set $HTTP_COOKIE_VARS[TestCookie]";
}
else
{
echo "Cookie was not set";
}
}
?>

My question is:

I just want to set a GET variable but I want it to be hidden to the page's viewers, can I? Because it (GET variable) looks ugly in the URL, and one more thing, if the user delete the GET variable from the URL and hit enter, the cookie will be recreated!

So, I want to get rid of the GET variable?

I apreciate your kind help :)

Posted: Thu Feb 27, 2003 7:09 pm
by hedge
the only way you could hide the get var is to make it a form with a hidden input. Why not just check for the existance of the cookie to decide wether to set it or not?

Posted: Fri Feb 28, 2003 12:32 am
by decoy1
Use POST instead of GET.

GET sends <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> via the querystring, POST via HTTP headers