Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2018-01-17 22:40 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (206 votes). Check out past polls.