Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Structure of a custom class (using Apache::Session)

by barrachois (Pilgrim)
on Jun 16, 2005 at 15:13 UTC ( #467306=note: print w/replies, xml ) Need Help??

in reply to Structure of a custom class (using Apache::Session)

I've been doing similar things regularly, and finally over the last few weeks have been trying to pack my regular practice into a CPAN compatible module.

My two modules are Object::Generic and Object::Generic::Session. Using them (in HTML::Mason, here) looks something like this:

# -- file httpd.conf -- # (Define the session global.) PerlAddVar MasonAllowGlobals $session # -- file htdocs/autohandler - # (Retrieve the session; process webpage.) % $session = new Object::Session::Generic( % session_config => { Store=>'MySQL', ... }, % cookie_name => 'your cookie name here', % expires => '+8h', % ); % $m->call_next; % $session = undef; # -- file htdocs/file.html -- # (Use the session to access key/value pairs.) <html> % if ($username){ % $session->user( % new Object::Generic( name => $username ) % ); % } % if ($session->user){ Hi <% $session->user->name %>. Welcome back. % } else { <form> Please log in: <input type="text" name="username" /> </form> % } </html> <%args> $username => '' </%args>

You can find Object::Generic and Object::Generic::Session at if you want to check them out.

Update: I've just uploaded v0.02 of both of these to CPAN.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://467306]
and the pool shimmers...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2017-01-21 21:48 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (186 votes). Check out past polls.