HTTP Sessions

Vance Dubberly vance at coloradosprings.com
Fri Dec 7 13:31:03 CST 2001


PHP 4 stores a cookie in the browser containing a unique session ID with a
scope of  session, if cookies are disabled it automatically rewrites all
your URL's to contain the session ID.  It keys that session ID to the name
of a tmp file which holds your name=value pairs for your session variables,
JSP does the same thing.  I would bet that there is a perl module for doing
this, but we don't use perl for frontend anymore so I don't know.
Possibilities would be CGI.pm or one of it's extensions.  Writing a session
class is pretty easy though, only thing is if cookies are disabled you'll be
hurting, parsing all your URL can really suck depending on how you laid out
your architecture.

vance

-- 
Vance Dubberly
Freedom Interactive Newspapers of Colorado
4575 Galley Road, Suite 400c
Colorado Springs, Colorado  80915
tel  719.577.4848
fax  719.577.4420
-------------------------------------------
ColoradoSprings.com, Your Community Connection!
Gazette.com, What Do You Want to Know?
 WOW! Marketing, Inc.,  Clever. Creative.
-------------------------------------------
Of all the beautiful things in the world
I believe that which is most beautiful is
the man who can see beauty anywhere he looks.



On 12/7/01 12:09, "Matthew J. Long" <matt.long at matthew-long.com> wrote:

> It just seems strange to me that there is not a simpler abstraction of this.
> In PHP4, for instance, you can create a session object and store variables
> between pages without giving it much thought. This doesn't appear to write a
> cookie either, so I'm not sure how it works in PHP, but I figured there
> should be something as simple as this to use with perl. What I'd really like
> is an interface for writing my own perl objects that can be easily
> persisted. For instance, something like this would be nice:
> 
> # create the session
> my $session = new HTTP::Session();
> 
> my $object = new MyObject($session); # sets on the object will update the
> value in the session object.
> 
> $object->setName("New MyObject Object");
> 
> $session->store();
> $session->close();
> 
> # use the session later in another CGI
> my $session = HTTP::Session::getSession();
> 
> my $object = new MyObject($session); # session values are assigned to the
> appropriate instance variables upon instatiation
> 
> my $name = $object->getName();
> 
> print "Content-type: text/html\n\n";
> 
> print "The object name is: $name<br>\n";
> 
> print $session->close();
> 
> etc.....







More information about the Pikes-peak-pm mailing list