1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#!/usr/bin/perl -w
#
# Fichier session.cgi
#
use strict;
use warnings;
use CGI qw/:all *table start_ul/;
use CGI::Pretty;
use CGI::Carp qw(fatalsToBrowser);
use CGI::Session;
use DBI;
my $host = 'localhost';
my $database = 'User';
my $user = 'test';
my $password = 'test';
my $session;
my $dsn = "DBI:mysql:database=$database;host=$host";
my $dbh = DBI->connect($dsn, $user, $password) or die "Echec connexion";
$session = new CGI::Session("driver:MySQL", undef, {Handle=>$dbh});
my $CGISESSID;
$CGISESSID = $session->id();
print $session->header();
print start_html( -title=>'Test Session' );
$session->expire('+1h');
$session->param('test', 'valeur');
print a({-href=>'./sessionload.cgi'}, "Cliquer"); |
Partager