ahvceo Posted May 19, 2009 Share Posted May 19, 2009 Hi All, I am 72 and just trying to learn php, it wasn't around when I was programming 20 years ago. I got this code off of the web and I don't quite understand what is happening! I do know that the $_GET statement returns the reefer's username from the affiliate link but that is about all. if($_GET['ref']) { if($cookieExpiration != 0) $cookieLifetime = time() + $cookieExpiration*86400; else $cookieLifetime = time() + 3650*86400; SetCookie ("ref",$_GET['ref'], $cookieLifetime, $cookiePath, $cookieDomain); SetCookie ("ref",$_GET['ref'], $cookieLifetime, $cookiePath, $cookieDomain); SetCookie ("ref",$_GET['ref'], $cookieLifetime, $cookiePath, $cookieDomain); SetCookie ("ref",$_GET['ref'], $cookieLifetime, $cookiePath, $cookieDomain); SetCookie ("ref",$_GET['ref'], $cookieLifetime, $cookiePath, $cookieDomain); as you can see there are 4 Set "SetCookie" statements in a row that look identical to me. Is there a difference in what each statement does? In a different php file I want to use the following code... $myFile = 'testFile.txt'; $fh = fopen($myFile, 'a') or die("can't open file"); $ref = $HTTP_COOKIE_VARS["ref"]; while (list (WHAT GOES HERE, AND HERE, AND HERE)=each ($HTTP_COOKIE_VARS)) fwrite($fh, "WHAT GOES HERE"); fclose($fh) to read the cookie I just set with the previous statements and write them out to a file so I can see what is returned. Is "$HTTP_COOKIE_VARS" a good statement? I read some where that it was depreciated and replaced with a new statement. Since I don't know what or how many variables are being returned what goes where I have written "WHAT GOES HERE", AND HERE, AND HERE" in the code above? There were 2 variables in the list or orginally. Thanks ahvceo PS What is wrong with this text editor? I cannot see the bottom of the page after a few lines. Why doesn't someone fix it? Quote Link to comment https://forums.phpfreaks.com/topic/158714-solved-setting-and-getting-cookies/ Share on other sites More sharing options...
waynew Posted May 19, 2009 Share Posted May 19, 2009 //set a cookie setcookie("name","Wayne"); //get said cookie $name = $_COOKIE['name']; //print $name echo $name; //Will be Wayne You're right. $HTTP_COOKIE_VARS is pretty outdated. $HTTP_COOKIE_VARS is now $_COOKIE $HTTP_POST_VARS is now $_POST $HTTP_GET_VARS is now $_GET Quote Link to comment https://forums.phpfreaks.com/topic/158714-solved-setting-and-getting-cookies/#findComment-837102 Share on other sites More sharing options...
ahvceo Posted May 20, 2009 Author Share Posted May 20, 2009 Hi Wayne, Yjanks for the information. How about the first part of my question? Is there any difference between the statements of does it just write yhe same cookie 54 times? Thabks again ahvceo Quote Link to comment https://forums.phpfreaks.com/topic/158714-solved-setting-and-getting-cookies/#findComment-837788 Share on other sites More sharing options...
MadTechie Posted May 20, 2009 Share Posted May 20, 2009 They look look identical to me as well so will all do the same thing.. well technically if you used all of them then only the first one will create a cookie if it doesn't exist, the rest would update it .. but if only one of those existed it wouldn't matter which one Quote Link to comment https://forums.phpfreaks.com/topic/158714-solved-setting-and-getting-cookies/#findComment-837791 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.