Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

CGI Session information

by packetstormer (Monk)
on Apr 12, 2012 at 13:49 UTC ( #964761=perlquestion: print w/ replies, xml ) Need Help??
packetstormer has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks

I have built a web application that uses CGI to create and store users information across pages. It all works well but I would like to create an Admin interface that will allow an Admin to view the sessions tables to see who is logged in a purge the table if it gets to big/stale etc.

Does anyone know of any scripts to pulls session information out of the sessions table when the session is not yours? That is, I want ALL session information not just mine (my session id). The session table is as default with just an id and a_session column. The a_session seems to be stored in a hash format (kind of) and I surely could get it out, parse it and display it but before I reinvent the wheel does anyone know if such a feature exists in a CGI tool?

Thanks

Comment on CGI Session information
Re: CGI Session information
by thomas895 (Hermit) on Apr 12, 2012 at 16:32 UTC

    I don't know of any from the top of my head, but if you use the default session data serializer(Data::Dumper), then you can easily deserialize it, or even just eval it directly(not always advisable).

    See the source of CGI::Session::Serialize::default for a great example.

    ~Thomas~
Re: CGI Session information
by mbethke (Hermit) on Apr 12, 2012 at 16:47 UTC

    Edit: nah, forget it---misunderstood the problem

Re: CGI Session information
by Anonymous Monk on Apr 13, 2012 at 05:09 UTC

    Does anyone know of any scripts to pulls session information out of the sessions table when the session is not yours?

    Wait, what? Who created this session table? Are you using some module?

Re: CGI Session information
by Anonymous Monk on Apr 13, 2012 at 11:40 UTC
    A web "session" mechanism always works the same way: a cookie and/or part of the URL string contains a randomly-generated identifier which is used as the primary key of a session-information table containing whatever data the server wishes to store. It's usually a good idea for that information to include the primary-keys of other tables, such as info about who is logged on and even ("in the bigger scheme of things") what that "person" is currently doing. There are gobs of session-handling modules in CPAN, with thorough descriptions of how they work.
      A web "session" mechanism always works the same way: a cookie and/or part of the URL string contains a randomly-generated identifier which is used as the primary key of a session-information table containing whatever data the server wishes to store. It's usually a good idea for that information to include the primary-keys of other tables, such as info about who is logged on and even ("in the bigger scheme of things") what that "person" is currently doing. There are gobs of session-handling modules in CPAN, with thorough descriptions of how they work. http://methoo.com
Re: CGI Session information
by thargas (Deacon) on Apr 13, 2012 at 12:12 UTC

    It seems from your description that you are already doing sessions somehow and that you didn't write the session handling code. In which case, you'll have to tell us which session module you're using for us to be able to help you.

    If you're using CGI::Session, then you want the find() method.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://964761]
Approved by marto
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (13)
As of 2014-10-24 14:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (132 votes), past polls