#!/usr/bin/perl -w # # customized.pl # Set cookies for layout/color preferences # # Build HTML form (see http://www.cederholm.tv/customize for example) and this little # script will set 3 cookies for each value submitted. Replace "yourdomain.com" # with ... well, your domain. For retrieving, see the bottom of the script. # # Dan Cederholm # dan@cederholm.tv # use strict; use CGI qw/:standard/; use CGI::Cookie; # Set variables my $q = new CGI(); my $colorValue = $q->param("color"); my $fontValue = $q->param("font"); my $sizeValue = $q->param("fontSize"); # Color scheme my $cookieColor = new CGI::Cookie( -name=>'color', -value=>$colorValue, -domain=>'.yourdomain.com', -expires=>'+1y',); print "Set-Cookie: $cookieColor\n"; # Font face my $cookieFont = cookie( -name=>'font', -value=>$fontValue, -domain=>'.yourdomain.com', -expires=>'+1y',); print "Set-Cookie: $cookieFont\n"; # Font size my $cookieSize = cookie( -name=>'fontSize', -value=>$sizeValue, -domain=>'.yourdomain.com', -expires=>'+1y',); print "Set-Cookie: $cookieSize\n"; # Redirect to homepage print "Location: http://www.yourdomain.com/\n\n"; exit; # Wanna retrieve those cookie values? It's as simple as... # # my $color = $q->cookie('color'); # my $font = $q->cookie('font'); # my $fontSize = $q->cookie('fontSize');