Cookies

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JWest46088
    New Member
    • Sep 2006
    • 74

    Cookies

    Can someone show me an example on how to use cookies?

    I've been trying to find an easy example online, but I don't understand them.

    Here is what I got out of it, but it doesn't work:

    Code:
    use CGI qw/:standard/;
    use CGI::Cookie;
    $cookie = new CGI::Cookie(-name => 'filename', -value => 'grades');
    $cookie2 = new CGI::Cookie(-name => 'direction', -value => 'Reverse');
    print header(-cookie => [$cookie, $cookie2]);
    %cookies = fetch CGI::Cookie;  
    $filename = $cookies{'filename'} -> value;
    $direction = $cookies{'direction'} -> value;
    print "Set-Cookie: $cookie\n";
    I'm assuming that the -name is the name field in the form and the -value is the value field but who knows.
  • JWest46088
    New Member
    • Sep 2006
    • 74

    #2
    So, if I have a form with a text box whose name is filename and value is whatever is put in the textbox and three radio buttons with the name direction and values forward, reverse, and reversebackward . How would I make a cookie so that if the user leaves the page, they will get the same filename they put in the textbox and the same direction radio button they selected when they return to the page?

    Comment

    • numberwhun
      Recognized Expert Moderator Specialist
      • May 2007
      • 3467

      #3
      Originally posted by JWest46088
      So, if I have a form with a text box whose name is filename and value is whatever is put in the textbox and three radio buttons with the name direction and values forward, reverse, and reversebackward . How would I make a cookie so that if the user leaves the page, they will get the same filename they put in the textbox and the same direction radio button they selected when they return to the page?

      Sorry, I don't know the answer but hopefully one of our experts will be able to assist you.

      My appologies for the delay in getting an answer to your question.

      Regards,

      Jeff

      Comment

      Working...