in reply to Re^2: searching for small Cookies example but found does not work
in thread searching for small Cookies example but found does not work

print "$cookie\n"; print "Content-type: text/html\n\n"; print "Have we a cookie?????\n";

If you mean you can't see the actual cookie printed it is because you print it before sending content-type headers... Try moving all print statements you want to appear on your browser after printing content-type headers. And btw that \n\n should have been \r\n or more accurately:

... For example, most networking protocols expect and prefer a CR+LF ("\015\012" or "\cM\cJ" ) 

It is for these trivial mistakes that CGI can save you a lot of trouble if not time. Here is how to set a cookie on client's browser:

use CGI; my $cgi = CGI->new; my $cookie = $cgi->cookie(-name => 'CookieName', -value => 'CookieVal +ue' ...); print $cgi->header( -cookie => $cookie, -type => 'text/html'); #print "just set a cookie on you<br>" print $cgi->start_html("just set a cookie on you<br>");

Replies are listed 'Best First'.
Re^4: searching for small Cookies example but found does not work
by marto (Cardinal) on Jul 31, 2018 at 11:13 UTC

    Looks like OP is just getting started. CGI states:

    "The rationale for this decision is that CGI.pm is no longer considered good practice for developing web applications, including quick prototyping and small web scripts. There are far better, cleaner, quicker, easier, safer, more scalable, more extensible, more modern alternatives available at this point in time. These will be documented with CGI::Alternatives.

    Mojolicious would be my recommendation, even with Mojolicious::Lite Signed cookie based sessions (with a cryptographic signature to prevent messing around) just work out of the box.

    Update: fixed typo.

      Molicious: Contraction of moustache and delicious. Generally sarcastic, and particularly applies to porno moustaches and their wearer.

      One's tongue can't make that big a slip with the word "CGI(.pm)"! or can it?

      I have never written anything with Mojolicious, that's why I did not cite. My first and mainly negative impression with that (from their hello world app, which is the very first thing you see on their website) was that one had to deploy a Mojo-supplied webserver. That always makes me run away, am I wrong in that impression?

        The example on the first page shows :

        "To run this example with the built-in development web server just put the code into a file and start it with morbo."

        For more details see Deployment. documentation/Tutorial are worth reading. For all of the reasons quoted above, recommending CGI to someone who looks like they're just getting started seems like a bad idea to me (and apparently the people who maintain CGI).