Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jan 2010
    Posts
    79
    Thanks
    1
    Thanked 0 Times in 0 Posts

    problem with session (CGI::Session)

    I have a problem with CGI::Session.
    I initialize a session at login with login.cgi script, but
    how can I retreive my session id or data when I stand in other html
    pages or scripts.
    I saw that CGI.pm has not a method to retreive session data.
    How can solve this problem?

    Thanks in advance,
    Savio

  • #2
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,942
    Thanks
    2
    Thanked 169 Times in 164 Posts
    You need to create a CGI::Session object and use that object to retrieve the session data.

  • #3
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    http://search.cpan.org/~markstos/CGI...CGI/Session.pm
    http://search.cpan.org/~markstos/CGI...on/Tutorial.pm

    I hope you come back with questions after reading those.

    Make sure, as well, that you put the code for the session in the correct files, especially if using several files to compile a web page. That was the thing I found least reading material about and where the biggest of my issues were, which, of course, were fixed with the help of FishMonger.

    You mentioned that you wanted to use the session in html pages. I doubt you can if you store the session on the server.

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #4
    New Coder
    Join Date
    Jan 2010
    Posts
    79
    Thanks
    1
    Thanked 0 Times in 0 Posts
    You need to create a CGI::Session object and use that object to retrieve the session data.
    If I create a new CGI::Session object, then I create new session and new coockies, instead I want to use session already in use.

    I read above documentation.

    You mentioned that you wanted to use the session in html pages. I doubt you can if you store the session on the server.
    In fact, but how can I retreive that informations by methods without creating new session?

  • #5
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,942
    Thanks
    2
    Thanked 169 Times in 164 Posts
    When you create the object, use load instead of new.

    http://search.cpan.org/~markstos/CGI....pm#load%28%29

  • #6
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    Quote Originally Posted by dark0s View Post
    If I create a new CGI::Session object, then I create new session and new coockies, instead I want to use session already in use.

    I read above documentation.
    From cpan tutorial:
    Whenever you're ready to create a new session in your application, do the following:

    $session = new CGI::Session() or die CGI::Session->errstr;

    Above line will first try to re-initialize an existing session by consulting cookies and necessary QUERY_STRING parameters. If it fails will create a brand new session with a unique ID, which is normally called session ID, SID for short, and can be accessed through id() - object method.
    hth

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #7
    New Coder
    Join Date
    Jan 2010
    Posts
    79
    Thanks
    1
    Thanked 0 Times in 0 Posts
    My code session in login.cgi is the following:
    my $session = new CGI::Session(undef, undef, {Directory => '/tmp'});
    $session->param(-name => '_CLIENT', -value => $columns[0]);
    $session->param(-name => '_EMAIL', -value => $columns[1]);
    $session->expire('+1h');
    and generate a specific id for session.
    My problem is how can retreive that specific id in search.cgi or index.html?

  • #8
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    I use this in my perl files.

    my $session_id = $session->id();


    hth
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •