PHP Classes

File: cookie_set.php

Recommend this page to a friend!
  Classes of Brian Moon   SiteCookie   cookie_set.php   Download  
File: cookie_set.php
Role: Example script
Content type: text/plain
Description: Example of how to set the contents of a SiteCookie
Class: SiteCookie
Author: By
Last change: Made the script use $_COOKIE for echoing values.
Date: 21 years ago
Size: 641 bytes
 

Contents

Class file image Download
<?php
   
// Include the Class
   
include "SiteCookie.php";
   
   
// Create a local object
   
$SiteCookie=new SiteCookie("test_cookie");
   
   
// Add the variables to be saved in the cookie
   
$SiteCookie->put("namefirst","Jo");
   
$SiteCookie->put("namelast","Foo");
   
$SiteCookie->put("number","1234");
   
$SiteCookie->put("time",time());

   
// Set the cookie
   
$SiteCookie->set();
   
    echo
"<br>The values saved in the cookie test_cookie are:";
    echo
"<br>namefirst: = $_COOKIE[namefirst]";
    echo
"<br>namelast: = $_COOKIE[namelast]";
    echo
"<br>number: = $_COOKIE[number]";
    echo
"<br>time: = $_COOKIE[time]";
    echo
"<br><br>END";

?>