Skip to content

Instantly share code, notes, and snippets.

@davidsan
Created April 9, 2013 17:38
Show Gist options
  • Select an option

  • Save davidsan/5347719 to your computer and use it in GitHub Desktop.

Select an option

Save davidsan/5347719 to your computer and use it in GitHub Desktop.
#!/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