Sitellite Application Framework
Class Tree         Index         All Elements

Class: Cookie

Source Location: Program_Root/CGI/Cookie.php

Class Overview


Cookie is a class that is used to give auto-generated Cookie variables their own distinct namespace, so as not to conflict with other auto-generated variables, such as CGI data. The Cookie class gets its data from the $HTTP_COOKIE_VARS hash.


Author(s)

Version

  • 2.2, 2002-11-01, $Id: Cookie.php,v 1.2 2005/07/06 15:30:56 lux Exp $

Copyright

  • Copyright (C) 2001-2003, Simian Systems Inc.

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 78]
Cookie is a class that is used to give auto-generated Cookie variables their own distinct namespace, so as not to conflict with other auto-generated variables, such as CGI data. The Cookie class gets its data from the $HTTP_COOKIE_VARS hash.

New in 1.2:

  • Added support for the PHP $_COOKIE, etc. variables, via an if statement so as to be backward-compatible with the deprecated $HTTP_*_VARS variables.
New in 1.4:
  • Added the prependDot() method.
New in 1.6:
  • Now relies on the $_COOKIE superglobal only, but calls "global $_COOKIE;" so that in versions of PHP below 4.1.0, you can create a reference to the old $HTTP_*_VARS using the new $_* names.
New in 1.8:
  • Fixed a bug with the automatic stripslashes() and fields that are arrays.
New in 2.0:
  • Removed a preg_match() call and replaced it with a substr_count call, which is faster AND more effective, in the prependDot() method.
New in 2.2:
  • Fixed a syntax error that was causing problems with cookies with positive expiry times.

1 <?php
2
3 $cookie = new Cookie;
4
5 if (! empty ($cookie->session_id)) {
6 // do something with the cookie
7 } else {
8 // set the cookie
9 $cookie->set ("session_id", "value", 1800, "/", ".site.com", 0);
10 }
11
12 ? >




Tags:

access:  public
version:  2.2, 2002-11-01, $Id: Cookie.php,v 1.2 2005/07/06 15:30:56 lux Exp $
license:  http://www.sitellite.org/index/license
copyright:  Copyright (C) 2001-2003, Simian Systems Inc.
author:  John Luxford <mailto:lux@simian.ca>


[ Top ]


Class Variables

$param = array ()

[line 86]

Contains a list of the names of all the cookie variables available to the current script.



Tags:

access:  public

Type:   mixed


[ Top ]



Class Methods


constructor Cookie [line 94]

Cookie Cookie( )

Constructor method.



Tags:

access:  public


[ Top ]

method prependDot [line 127]

string prependDot( string $domain)

Returns the domain passed to it, with a prepended dot (.) if

the domain contains only a single dot (since the cookie specs say that two dots are required). This is a workaround that lets us pass our Session object a $site with a domain like 'yoursite.com', and have it automatically know to set the cookie for '.yoursite.com'.




Tags:

access:  public


Parameters:

string   $domain  

[ Top ]

method set [line 153]

boolean set( [string $name = ''], [string $value = ''], [integer $expire = ''], [string $path = ''], [string $domain = ''], [boolean $secure = 0])

Sends a 'set-cookie' HTTP header to the browser. Must be called before any data has been sent.

$expire is the number of seconds from the current time. $domain must contain at least two periods (.). $secure accepts a 1 or a 0 to denote true or false.




Tags:

access:  public


Parameters:

string   $name  
string   $value  
integer   $expire  
string   $path  
string   $domain  
boolean   $secure  

[ Top ]


Copyright © 2007, SIMIAN systems Inc.
All rights reserved. Privacy policy
Documentation generated on Tue, 13 Feb 2007 17:17:07 -0600 by Sitellite AppDoc and phpDocumentor 1.2.2