in reply to Re: Re: Re: Problem retrieving session cookies
in thread Problem retrieving session cookies

Thanks for your response Ben. I finally got it to work (somewhat). When I moved the print "Content-type: text/html\n\n"; until after the calls to the cookie it worked. Now looks like this:
$q = new CGI; my $cookievalue = $q->cookie('User_Session'); $initcookie = $q->cookie( -name=>'User_Session', -value=>'abc', -path=>'/', -domain=>'www.thedialogcenter.com', -secure=>0 ); print $q->header(-cookie=>$initcookie); print "Content-type: text/html\n\n"; print "The cookie value is : $cookievalue<br>";
My first question is why (I hate doing things that work that I don't understand). My second question - is there a way to set the cookie after the "Content-type" has been set? Third questions -why do my questions not show up in the main list of questions. And finally, why do I no longer get an email when someone responds. I asked a question a while ago about sessions and got some GREAT responses that I never looked at because I thought I would get an email when they responded. Thats in advance for answers to any of my questions.

Replies are listed 'Best First'.
Re: Re: Problem retrieving session cookies
by benn (Vicar) on Apr 10, 2003 at 14:27 UTC
    in order....
    • You need to create the cookie, then print the cookie...It looks like you should be getting duplicate header/cookie lines there - the "print $q->header(-cookie...)" *should" do exactly the same as your next two print statements. If not, try "$q->header({-cookie=>$initcookie})" - I've known some versions of CGI.pm not like named params unless they're an anon. hash.
    • Yes - you can print the "Content-type" header, set your cookie, then print the cookie, as you can do above simply by moving the $initcookie initalisation down two lines. If you do this, you don't need to use $q->header();
    • If you mean the 'Monastery Gates' (the front page), then only certain questions make it on there - particularily interesting, informative or challenging ones usually. If you mean the "Seekers Of Perl Wisdom" section, then occasionally there may be a delay while your question is 'approved' - or maybe deleted if the question is seen as irrelevant / non-perl / flaming etc.
    • I don't *think* there's an email bot around - but in your 'preferences' you can tick the "show me when I get a response to posts" box though to receive notifications in the Chatterbox
    Hope this helps.

    Cheers,
    Ben
      Thank you again Ben. Your pointers helped tremendously. I now have it working. To get it to work I had to remove the print "Content-type: text/html\n\n" line. After removing that line, everything worked like a charm. Prior to that it just would not save or recall the cookie. You made my morning!
      - Mark