Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

CGI::Session multiple cookies

by RaginElmo (Novice)
on Oct 11, 2005 at 17:05 UTC ( [id://499221]=perlquestion: print w/replies, xml ) Need Help??

RaginElmo has asked for the wisdom of the Perl Monks concerning the following question:

Heya Monks, looking for some wisdom cauz I am lost in the sessions... Running IIS5 & Activestate Perl (can't help it) index.pl looks like this:
... my $session = new CGI::Session(undef, undef, {Directory=>'c:\perl\temp +\sessions'}); $session->param('UID', $UID); $session->param('UNME', $UNME); $session->param('GID', $GID); print $session->header(); ...
When I debug I can see the header: Set-Cookie: CGISESSID=3b488a17c9cce9bc4dcf4654db65364c; path=/ and IE says it accepted the cookie. However When loading a new framepage using the same
my $session = new CGI::Session(undef, undef, {Directory=>'c:\perl\temp +\sessions'});
which should check if the cookie is already created, a new cookie is generated, therefore loosing all my session details. Any ideas? Thanks!

Replies are listed 'Best First'.
Re: CGI::Session multiple cookies
by RaginElmo (Novice) on Oct 11, 2005 at 20:28 UTC
    Oops... need to retrieve the cookie from client...
    my $cgi=new CGI; my $sid = $cgi->cookie("CGISESSID") || undef; my $session = new CGI::Session(undef, $sid, {Directory=>'c:\perl\temp\ +sessions'});
Re: CGI::Session multiple cookies
by tomazos (Deacon) on Oct 11, 2005 at 17:35 UTC
    Are you setting the cookie on a different domain to where you want it sent back? If so, this is not allowed for security reasons. The web browser will ignore you and send no cookie header. This makes your server think you don't have a cookie and it generates a new one.

    -Andrew.


    Andrew Tomazos  |  andrew@tomazos.com  |  www.tomazos.com
Re: CGI::Session multiple cookies
by RaginElmo (Novice) on Oct 11, 2005 at 17:47 UTC
    No I am using HTML templates and it just loads a relative link. First page is index.pl which creates a HTML page.
    <FRAME src="left.html" name="left" scrolling="no" noresize> <FRAME src="main.pl" name="main" scrolling="auto" noresize>
    so there is no change of domain/server
Re: CGI::Session multiple cookies
by RaginElmo (Novice) on Oct 11, 2005 at 19:39 UTC
    To simplify #session.pl
    # Object initialization: use CGI::Session; $session = new CGI::Session(undef, undef, {Directory=>'c:\perl\temp\se +ssions'}); # send proper HTTP header with cookies: print $session->header(); print $session->header(); print "click <A href='session2.pl'> here";
    #session2.pl
    # Object initialization: use CGI::Session; $session = new CGI::Session(undef, undef, {Directory=>'c:\perl\temp\se +ssions'}); # send proper HTTP header with cookies: print $session->header(); print $session->header();
    the double print is to show the session on the page.
    both times the cookies are set in Firefox but change the moment I click to next page. Host and path are both the same...

    ...insane in the membrane...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://499221]
Approved by pboin
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-24 08:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found