Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: always logged in with CGI::Session

by bibliophile (Parson)
on Mar 24, 2006 at 15:31 UTC ( #539048=note: print w/replies, xml ) Need Help??

in reply to always logged in with CGI::Session

Hi boboson, I'm just figuring out CGI::Session myself...
I think you have a typo - $session->expires shouldn't have the 's', according to the docs: CGI::Session

I'd think that you would want to expire the session after a shorter period of inactivity....?

Update: There's a section on this in the tutorial.

Hope that helps :-)

Further update: I'm wondering about something... does your module always give the session(s) the same session id? I admit that I haven't played with CGI::Session->name()... :-/

-- WARNING: You are logged into reality as root.

Replies are listed 'Best First'.
Re^2: always logged in with CGI::Session
by boboson (Monk) on Mar 24, 2006 at 19:32 UTC
    Yep, your'e right the (s) shouldn't be there. However it still works with the (s)??? Don't ask me why!
    I read in a post doing a supersearch that if you don't supply the expire, the session would expire when the browser window is closed. This doesn't seem to be true, or it is true and my application always gives me the same sessionid.
    It sure feels like it always gives me the same session id. I use the name() function to shorten the "CGISESSID" name variable to just "sid", because if a user doesn't have cookies activated I can send the sessionid with a name of my choice like this:
    # get sessionid for querystring if ($q->cookie('sid') ne $session->id()) { $tmpl->param(sid => "&sid=".$session->id()); }
    Do you have any clue how to prevent the same sessionid to be set?
      Sorry, I've been out of the office for the last week :-)

      I'm only guessing here... but take a look at: session_config. Maybe you want to use that in your init_session routine, rather than using CGI::Session->name()?

      Let me know if that changes anything - I'm quite curious (as I'll be needing something like this myself in a while!)


      -- WARNING: You are logged into reality as root.
        I am not sure yet, haven't done to much testing. But it seems to work. I removed the name and the session header calls.
        sub init_session { # application object my $self = shift; my $name = shift; # change name from CGISESSID to shorter sid #CGI::Session->name($name); # init session object using CGI::Application::Plugin::Session my $session = $self->session; # send session to header #$session->header(); }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://539048]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2018-03-18 17:20 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (230 votes). Check out past polls.