Forum Moderators: coopster
setcookie("var1",$v1,time() + 86400,"/");
setcookie("var2",$v2,time() + 86400,"/");
setcookie("var3",$v3,time() + 86400,"/");
I wonder if I can have this in one line. I tried adding one variable value after another in a same fashion and it did not work. Sorry about ignorance.
The next two questions are rather conceptual then asking about how to write exact code:
Another question is about check process if cookie has already been set as people go through pages of the site.
My understanding is that initial code will be at the very top of each page as we never know which page will be the entry one. So you get onto Page1, and than click onto a link for Page2.
If you get the same code over there again, will the server “know” cookie is already there, or I have to put additional code and check?
Finally, how do I deal with people that came back again, this time by entering my site’s address directly (like bookmarking it). My goal is to get my variables through which are nothing else but keywords and domain names from referring links.
Thanks
2. For returning users, depending on what you're trying to achieve, you can have a cookie expire when the user closes their browser (so when they come back it won't exist), or you can have a cookie expire after a long time. In your case, time() + 86400 will set the cookie to expire in the future so returning users will have them. If you set this parameter to 0 (I think it was 0, dbl check that..) then the cookie will be deleted at the end of the session.
GL
My end goal is to get the last query and last referrer link that had led to a sale.
So, if you click onto my Google AdWords ad, and 5 hours later, for any reason, you click onto my ad on Yahoo and buy something, I want that Yahoo referral going through.
Same with organic.
The other scenario is you come via search (paid or organic), you poke around, bookmark and close window. Tomorrow you come back via bookmark, and you buy something. If I set cookie to expire on window close, I will lose the original referring information.
My way would be that cookie should last until it gets overwritten by new data, if ever. Am I doing something wrong by thinking in this way?
If I'm not understanding you right, then sorry, anyone else have suggestions..?
All what I'm doing is exploding URL to get referrals like domain and keywords. I have three variables in total. If all three are presented cookie shows all of them so my domain shows three times as well. It is always one cookie only.
At the end, it can stay like that. I just wondered if three variables can be written in one line, rather than three like in my example.