Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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 http://cs.marlboro.edu/code/perl/modules/ if you want to check them out.

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


Comment on Re: Structure of a custom class (using Apache::Session)
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://467306]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (14)
As of 2014-07-25 21:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls