Not a Member Yet,
Click here to Register

ID: 120
Viewed: 3886
Added: Apr 17, 2002
Version:
Snippet uploaded by: snippet
Written By: smog
Demo: Sorry, no demo



User Rated at: 3 Stars3 Stars3 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

Another way to set a cookie in php. it also includes a date function for a time frame of a year.

<!---Head--->
none

<!---Body--->


 <?
// By José Afonso Santos aka smog
//
// smog@kaotik.org
// http://hero.kaotik.org/

// Delete a cookie.
setCookie('name');

// Getting the current date
$hour = date("H:i:s");
$year = date("y");
$year++; // Adding one year to the current year
$day = date("d-M-") . $year
$day_off_the_week = date("l");

// Setting the validation of the cookie up to one year.
$validation = $day_off_the_week . ", " . $day . " " .
$hour . " GMT";

// Set a cookie's value.
header("Set-Cookie: name=the-name-you-want;
expires=$validation; path=/");

// Create a cookie that only scripts in the
// private directory can read.
header("Set-Cookie: country=the-country;
expires=$validation; path=/private/");

// After the cookies are set, you can access them
// using normal PHP variables.
echo "<center>Hello <b>$name</b> !</center>";
?>


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2024 snippetlibrary.com All Rights Reserved. Conditions
Do NOT follow this link or you will be banned from the site!