IM trying to create a coookie in Perl but i cant seem to do it.

$cookies is a hash of the info i want to store ($cookie->{'postcode'}....).

The print "set cookie..." should create thr cookie but it doesnt.

Could anyone please help me...please

sub set_cookie <br> { <br> my ($expires,$domain,$path,$secure,$cookie) = @_; <br> my(@days) = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat");<br> my(@months) = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Se +p","Oct","Nov","Dec");<br> my($seconds,$min,$hour,$mday,$mon,$year,$wday) = gmtime($expires) +if ($expires > 0); #get date info if expiration set.<br> $seconds = "0" . $seconds if $seconds < 10; # formatting of date v +ariables<br> $min = "0" . $min if $min < 10; <br> $hour = "0" . $hour if $hour < 10; <br> my(@secure) = ("","secure"); # add security to the cookie if defin +ed. I'm not too sure how this works.<Br> if (! defined $expires) <Br> { <br> $expires = " expires\=Fri, 31-Dec-1999 00:00:00 GMT;"; <br> } # if expiration not set, expire at 12/31/1999 elsif ($expires == -1) <br> { <br> $expires = ""; <Br> } <br> else <br> { <br> $year += 1900; <br> $expires = "expires\=$days[$wday], $mday-$months[$mon]-$year $ +hour:$min:$seconds GMT; "; <br> }<br> if (! defined $domain) { $domain = $ENV{'SERVER_NAME'}; } #set d +omain of cookie. <br> if (! defined $path) { $path = "/"; } #set default path = "/"<br +> if (! defined $secure) { $secure = "0"; }<br><br> my $key;<br> foreach $key (keys %$cookie) <br> {<br><br> $cookie->{$key} =~ s/ /+/g; <br><br> print "Set-Cookie: $key\=$cookie->{$key}; expires=$expires; path=$ +path; domain=$domain \n\n"; <br><br> }<br><br> }<br>

In reply to Cant create a cookie! Please help by costas

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.