Hey, just need a little help I need a small sample code, split up into two sections with the aim of seeing if the user has visited one of the sister sites (though all it is another subdomain). need the code to write a cookie on one page and another code to check to see if the cookie exists, if it does do a msgbox saying "hi" via an if statement. can anyone help me with this please. Thanks Paul
That should not be too difficult... on subdomain A: setcookie ("IwasOnSubdomainA", time(), 0, "/", ".mydomain.com"); PHP: Then on your main site: if (isset ($_COOKIE["IwasOnSubdomainA"])) { $t = $_COOKIE["IwasOnSubdomainA"]; echo "Hi, you have been on subdomain A at " . date ("d/m/Y H:i:s", $t); } PHP: aXe
Thanks How would i make it write a new line on a textfile log.txt saying ip adress + time and date of visit?
Well getting the user IP is fairly easy but could also be very complex (depending whether your host is funky ) Personally I use the following: if (!empty ($_SERVER['HTTP_X_REAL_IP'])) $user_ip = $_SERVER['HTTP_X_REAL_IP']; else { if (!empty($_SERVER['REMOTE_ADDR'])) $user_ip = $_SERVER['REMOTE_ADDR']; else { if (!empty($_ENV['REMOTE_ADDR'])) $user_ip = $_ENV['REMOTE_ADDR']; else $user_ip = getenv('REMOTE_ADDR'); } } PHP: The time is already saved in the cookie, so just read that. I am pretty sure you can find out how to save in a text file fairly easily... tip: google is your friend lol aXe