in reply to Re^2: auto create cookies
in thread auto create cookies

i want to set cookies then continue doing other thing on same page

In which case, don't redirect.

Replies are listed 'Best First'.
Re^4: auto create cookies
by bigup401 (Pilgrim) on Jan 25, 2019 at 14:41 UTC

    if i dont redirect cookie failed to set itself

      As a counter-example showing this not to be true, here is an SSCCE. Enjoy.

      #!/usr/bin/perl -T use strict; use warnings; use CGI::Lite (); my $now = localtime (time ()); my $cgi = CGI::Lite->new; # Retrieve existing cookies my $cookies = $cgi->parse_cookies; my $oldcookie = defined ($cookies) ? $cookies->{bigup401} : 'not set'; # Set new cookie print "Set-Cookie: bigup401=$now\nContent-Type: text/html\n\n"; # Print the page print <<EOT; <p>Previous cookie value was $oldcookie<br /> New cookie value is $now</p> <p><a href="$ENV{REQUEST_URI}">Get next one</a>.</p> EOT exit;

        thanks