sub set_cookie { ########################################### # Create a cookie. We have a few different # "states" and all of them require at least # *some* user information # Uses a global CGI object ($p) to create # the cookie ########################################### # Get the passed user information my %ui = @_; # set the params for the cookie my $cookie = $p->cookie( -name => 'mycookie', -value => qq(Name:$ui{'Name'}:Phone:$ui{'Phone'}:EmployeeNum:$ui{'EmployeeNum'}:Email:$ui{'Email'}:SapId:$ui{'SapId'}:NTID:$ui{'NTID'}:Province:$ui{'Province'}), -expire => '', ); # send it to the browser print $p->header(-cookie => $cookie); } #### sub get_cookie { ################################################ #Retrieve the cookie #Uses a global variable ($p) for the CGI object #Returns user information ################################################ my %userinf; if ($p->cookie('mycookie')) { my $values = $p->cookie('mycookie'); %userinf = split /:/,$values; } else { display_login(); #No cookie, force a login } print $p->header(); return (%userinf); }