#!/usr/bin/perl -Tw #Cookietest use strict; use CGI::Carp qw/fatalsToBrowser/; use CGI qw(:all); $CGI::DISABLE_UPLOADS = 1; $CGI::POST_MAX = 1024*5; my $url = 'http://domain.tld/cgi-bin/cookie.pl'; my $domain = 'domain.tld'; my @chars = ("A".."Z", "a".."z",0..9); my $value = join( '', @chars[ map {rand @chars}(1..5)] ); my $cgi = CGI->new(); my $cookie = $cgi->cookie( '-name' => 'testcookie', '-value' => $value, '-expires' => 0, '-domain' => $domain, '-path' => '/' ); unless ( $cgi->param('redirected') ) { print $cgi->redirect( '-url' => $url.'?redirected='.$value, '-cookie' => $cookie, '-type' => 'text/html' ); } print $cgi->header( '-type' =>'text/html', '-charset' => 'utf-8' ); print $cgi->start_html( '-title' => 'Cookie Test' ); print $cgi->h1({},"Cookie Test"); print $cgi->p({}, "Zufallswert wird bei jedem Seitenaufruf im Cookie gesetzt", $cgi->br(), "und die Rückgabe des Browsers angezeigt." ); print $cgi->p({}, "Erwarteter Wert: ", $cgi->param('redirected'), $cgi->br(), "Empfangener Cookie Wert: ",$cgi->cookie('testcookie'), $cgi->br(), '$ENV{\'HTTP_COOKIE\'}: ',$ENV{'HTTP_COOKIE'} ); print $cgi->p({}, $cgi->a({'-href' => $url},'sende neuen Wert'), $cgi->br(), $cgi->a({'-href' => $url.'?redirected='.$cgi->param('redirected')},'nochmal Cookie abfragen'), ); print $cgi->end_html();