################################################################################ # Set cookie #!/usr/bin/perl -w use strict; print "Set-Cookie: state=1;\n"; print "Content-type: text/plain\n\n"; print "Set state to 1."; ################################################################################ # Set cookie with another value #!/usr/bin/perl -w use strict; print "Set-Cookie: state=2;\n"; print "Content-type: text/plain\n\n"; print "Set state to 2."; ################################################################################ # Get cookie #!/usr/bin/perl -w use strict; use CGI; use CGI::Cookie; my $cgi = new CGI; my $state = $cgi->cookie('state'); print "Content-type: text/plain\n\n"; print "The state is $state."; ################################################################################ # Set and get cookie via javascript Cookie demo