First Cut at Sessions (with cookies)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

First Cut at Sessions (with cookies)

Ken Treis-4
The attached parcel has a first cut at a session resource.  It'll
probably be easier to comment on some real code rather than my vague
descriptions.  I have a tendency to talk more than code on these
open-source projects, so I'm trying to redeem myself here.  :)

Because I still think that session management needs to be localized,
this resource manages its own sessions (rather than handing it off to a
global session manager).  The resource has a thread that expires
sessions, and it automatically starts and stops that thread as needed.  
It's kind of cool, IMHO.  Any resource below the CookieSessionResource
automatically gets a session attached to it.

The resource doesn't tell you if your session has expired; it just gives
you a new one transparently.  There's also a bit of an ugly hack in
there to try to figure out which path to assign to the cookie (in the
Set-Cookie header field).  Those are the two things that I might
change.  But it works for now.

I might also propose that we make a Cookie object.  Cookies are just
linearized dictionaries, and it'd be nice to parse them once and use
them as Dictionaries everywhere else.  The framework we have in place
for HeaderFields would handle them nicely.

To test this out, try the following lines in your sites.cnf:

<Site>
<SiteIdentifier ip: '127.0.0.1' port: 8080 host: 'localhost'>
<CookieSessionResource new>
  <SessionTestResource stringUriPattern: '/'>
</CompositeResource>
</Site>

Then, browse to localhost:8080.

There are no tests with this, since I was just playing.  But if people
like it, I'll add some tests and put it up on SourceForge.

Comments, please.


Ken

cookies.zip (6K) Download Attachment