Created
April 9, 2013 17:38
-
-
Save davidsan/5347719 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl -l | |
| use CGI; | |
| use CGI::Cookie; | |
| use Digest::MD5 'md5_hex'; | |
| use strict; | |
| my $q=CGI->new(); | |
| # building cookie | |
| my $rand=int(rand(10)); | |
| my $key=$q->param('nom').$rand; | |
| my $digest=md5_hex($key); | |
| open (FILE, ">cookie.txt"); | |
| print FILE $digest; | |
| close (FILE); | |
| my $cookie1 = CGI::Cookie->new(-name=>'authcook',-value=>$digest); | |
| print $q->header(-cookie=>[$cookie1]); | |
| print "coucou ", $q->param('nom'), " ", $q->param('prenom'), "<br>"; | |
| print "chiffre rand : $rand<br>"; | |
| print "$digest<br>"; | |
| my %cookies = CGI::Cookie->fetch; | |
| print "Feloches t'as le cookie" if $cookies{'authcook'}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment