By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,852 Members | 1,410 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,852 IT Pros & Developers. It's quick & easy.

Cookies

P: 74
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:

Expand|Select|Wrap|Line Numbers
  1. use CGI qw/:standard/;
  2. use CGI::Cookie;
  3. $cookie = new CGI::Cookie(-name => 'filename', -value => 'grades');
  4. $cookie2 = new CGI::Cookie(-name => 'direction', -value => 'Reverse');
  5. print header(-cookie => [$cookie, $cookie2]);
  6. %cookies = fetch CGI::Cookie;  
  7. $filename = $cookies{'filename'} -> value;
  8. $direction = $cookies{'direction'} -> value;
  9. print "Set-Cookie: $cookie\n";
  10.  
I'm assuming that the -name is the name field in the form and the -value is the value field but who knows.
Apr 4 '08 #1
Share this Question
Share on Google+
2 Replies


P: 74
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?
Apr 4 '08 #2

numberwhun
Expert Mod 2.5K+
P: 3,503
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
Apr 17 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.