25 users online (2 members and 23 guests)  


  Results 1 to 2 of 2

Related

  1. set multiple cookie    Forum: CGI Perl Forum
    Replies: 0
  2. Set-Cookie    Forum: CGI Perl Forum
    Replies: 1
  3. Perl cookie....    Forum: CGI Perl Forum
    Replies: 2
  4. Replies: 1
  5. cookie problem...    Forum: CGI Perl Forum
    Replies: 2
  1. #1
    slyen's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2007
    Posts
    2

    Lightbulb Set and get cookie using perl

    Hello,
    I am working on setting cookie on perl.
    when I did hard code sample cookie in the header ...
    Code:
     
    print "Set-Cookie: mycookie=testing;expires=Mon, 29-Jul-2008 15:00:00 GMT;domain=www3.cs.umanitoba.ca;path=/~umen/cgi-
    print "Content-type: text/html\n";
    print "Pragma: no-cache\n\n";
    when I tried to retrieve it using ...
    $ENV{HTTP_COOKIES}
    It is always empty ...
    Why?
    does anyone know how to solve this problem?
    Another thing is ... if I want to set the cookie after user has log in to a page and verified with his userid and password, what I can do?
    I tried to use
    print header(-cookie=>"Set-Cookie: name=value ....\n");
    my execution actually dies here....
    is my code right?
    Thanks

  2. #2
    pageBuzz.com's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2006
    Posts
    21

    Re: Set and get cookie using perl

    You have the order wrong. First define the content type, then the cookie then the extra stuff if you need it.

    print "content-type:text/html\n";
    print "set-cookie: value=$value; path=$path; expires=$expire\n\n";

    That will solve your problem.

    You can set your browser to warn you when a cookie is being set, that way you know when you access the page if it is working before trying to read it.



Tags for this Thread