aminnuto Posted October 25, 2006 Share Posted October 25, 2006 I currently have use this code[code]<?phpsession_start();if ($_SESSION['discount']){include('/home/pire/www/products/DISCOUNT-course.php');} else {include('/home/pire/www/products/REGULAR-course.php');$_SESSION['discount'] = "value";}?>but its only for the session and I want save it for the first 10 visits before it expires (or if thats not possible, expire after 10 days).Can anyone help me out with the code to do this?[/code] Link to comment https://forums.phpfreaks.com/topic/25095-help-how-do-i-create-a-cookie/ Share on other sites More sharing options...
gmwebs Posted October 25, 2006 Share Posted October 25, 2006 See how you get on with this?[code]<?php$session = md5(uniqid(rand()));SetCookie("CookieName", "$session", time() + 14400); // last number is expiration time in seconds, 14400 sec = 4 hrs// Print an individual cookieecho $_COOKIE["CookieName"];echo $HTTP_COOKIE_VARS["CookieName"];// Another way to debug/test is to view all cookiesprint_r($_COOKIE);?>[/code][url=http://uk2.php.net/setcookie]PHP SetCookie Reference[/url] Link to comment https://forums.phpfreaks.com/topic/25095-help-how-do-i-create-a-cookie/#findComment-114448 Share on other sites More sharing options...
aminnuto Posted October 25, 2006 Author Share Posted October 25, 2006 thanks. I'm kinda a novis to this. How would i implement that. Do i add the code to my existing code or do i alter it to point to my php files? Link to comment https://forums.phpfreaks.com/topic/25095-help-how-do-i-create-a-cookie/#findComment-114450 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.