Mark Lawrence > NCGI-0.12 > NCGI::Cookie

Download:
NCGI-0.12.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 0.12   Source  

NAME ^

NCGI::Cookie - HTTP Cookie object for NCGI

SYNOPSIS ^

  use NCGI::Cookie;

  # subroutine for reading cookies from the query
  my $hashref      = NCGI::Cookie::fetch();
  my $cookie_value = $hashref->{cookie_name};

  # object methods for creating cookies to send in the response
  my ($name, $value, $epoch, $path, $domain) =
    ('c1','value',1221397599,'/',undef);
  my $c = NCGI::Cookie->new(
    name    => $name,
    value   => $value,
    expires => $epoch,
    path    => $path,
    domain  => $domain,
  );

  # You can also "print $c->_as_string;"
  print $c; # c1=value; expires=Tue 07-Jun-2005 12:02:01 GMT; path=/

DESCRIPTION ^

NCGI::Cookie provides a simple HTTP Cookie object for Cookie creation, and a fetch subroutine to retrieve cookies sent by a browser.

SUBROUTINES ^

fetch

Returns a HASH reference containing all Cookies sent by the browser.

METHODS ^

new( ... )

Create a new NCGI::Cookie object with parameters 'name', 'value', 'expires', 'path' and 'domain'. Only 'name' and 'value' are really necessary as expires will automatically be filled in otherwise.

name

Set or Get the name of the cookie

value

Set or Get the value of the cookie. Will be scrubbed for illegal characters.

expires

Set or Get the expiration value of the cookie as a unix epoch.

max_age

Set or Get the expiration value of the maximum age of the cookie in seconds.

path

Set or Get the path of the cookie

domain

Set or Get the domain of the cookie

expire_cookie

Sets the expiration date of the cookie to 24 hours ago, effectively removing it from the browser cache.

_as_string

Returns the string representation of the cookie. The "" operator is overloaded so if you just 'print $cookie' you should also get the string representation.

SEE ALSO ^

NCGI::Query

AUTHOR ^

Mark Lawrence <nomad@null.net>

COPYRIGHT AND LICENSE ^

Copyright (C) 2005 Mark Lawrence <nomad@null.net>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.