Hidding GET variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
alsaffar
Forum Newbie
Posts: 16
Joined: Sun Sep 29, 2002 12:03 pm

Hidding GET variable

Post 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 :)
hedge
Forum Contributor
Posts: 234
Joined: Fri Aug 30, 2002 10:19 am
Location: Calgary, AB, Canada

Post 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?
decoy1
Forum Commoner
Posts: 50
Joined: Fri Feb 21, 2003 1:33 pm
Location: St. Louis

Post 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
Post Reply