hwg-basics archives | Jun 2000 | new search | results | previous | next |
Solved: Another Boring Cookie Questionby "Ben Bradley UK" <bradley(at)mudmail.co.uk> |
|
You may remember I asked a few questions a while ago wondering how to write a cookie to a user's computer from an intro page, and if they return they are redirected to another page if they have the cookie. Well if anyone is interested I've found out how to do it using PHP (cookies are far easier in PHP than in JavaScript) and here is the code I used if anyone wanted to know for future reference: <?php $exp = mktime(0,0,0,1,1,2001); if(!isset($start_cookie)){ setcookie ("start_cookie", "First Use", $exp); include("flashintro.html"); }else{ include("front.html"); } ?> The mktime() function sets the expiry date in seconds, minutes, hours, month, day, year format and the cookie then uses an include (like the call in SSI) to pull in the page depending on whether the cookie is set. This code must be placed at the top of a page before any HTML (including DOCTYPEs) and the file must be renamed to .php - this script does however depend on your webspace having PHP support. I hope this is useful to someone - they sent me an email requesting information if I ever found out but I no longer have their address. Ben Bradley UK Creative Director - The Net Zone http://www.thenetzone.co.uk FAX: 07080 810966 (From UK) PHONE: 07941 120956 (From UK)
HTML: hwg-basics mailing list archives, maintained by Webmasters @ IWA