Basically what i wanna do is drop a cookie on each person that comes to my site. If they come to my site again (with the cookie)....they automatically get redirected to another page. How do i do that? EDIT: I almost figured it out...but setting a cookie expiration doesnt work... this works.... <?php if (isset($_COOKIE['datecookie'])) { header("Location: http://www.website.com/"); exit; } $Month = time()+60*60*24*30; setcookie("datecookie"); ?> Code (markup): but this does not... <?php if (isset($_COOKIE['datecookie'])) { header("Location: http://www.website.com/"); exit; } $Month = time()+60*60*24*30; setcookie("datecookie", "", $Month); ?> Code (markup):
<?php if(isset($_COOKIE['datecookie'])) { header("Location: http://www.msn.com/"); } else { $month = time()+60*60*24*30; $value = "Hello"; setcookie("datecookie",$value, time() + 3600); } ?> Code (markup): This will work. Also use cookie editor and tamper data ff addon . Its good for php developers.
yep..that worked...thanks so much. follow up question: if i only want to drop the cookie if the person is leaving my site...is that possible? how would i do that? the reason is i dont want them to get redirected if they just refresh the page or click on another page of my site. i only want them to be redirected if they browsed my site and left...and then came back another hour or another day.
Good soln would be to store time in datecookie . When next u check whether cookie is set , just check whether the date or time diff is greater than u want. If it is just redirect them Reps will be highly appreciated .
so basically i give them a 10 minute window or so to navigate the site? that makes sense. how do i give you rep? you definitely deserve it. also, how do i do that btw? how do i test to see if the cookie has been set for at least 20 minutes?
http://www.weberdev.com/get_example-3307.html Here is a time diff function for you. Just store current time in cookie. And check using above function. You can give rep by clicking balance icon on every post on right hand above corner. Thanks and regards.
The value is stored in $_COOKIE['datecookie']. So when you're setting the cookie, do something like: setcookie("datecookie",time(), time() + 3600); PHP: Then to get the initial time and calculate the difference: $timedifference = timeDiff($_COOKIE['datecookie'], time()); PHP: