<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1020400" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1020400</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/issue-setting-cookies#comment-1124877</link>
    <description> &lt;p&gt;cookie-lib has been replaced with CGI.pm as of Perl 5.x. Please resist using any of the *-lib modules, including cgi-lib.pl. They&#039;re outdated and insecure.&lt;/p&gt;
 </description>
     <pubDate>Wed, 05 Feb 2003 09:39:18 +0000</pubDate>
 <dc:creator>Wil</dc:creator>
 <guid isPermaLink="false">comment 1124877 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/issue-setting-cookies#comment-1124830</link>
    <description> &lt;p&gt;if you don&#039;t want to use cgi.pm search for &quot;cookie-lib.pl&quot; -- i used it along time ago but i don&#039;t recall having any problems.  Even if you don&#039;t use it the code will help you with your own implementation.&lt;/p&gt;
 </description>
     <pubDate>Tue, 04 Feb 2003 17:22:29 +0000</pubDate>
 <dc:creator>ROB</dc:creator>
 <guid isPermaLink="false">comment 1124830 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/issue-setting-cookies#comment-1124825</link>
    <description> &lt;p&gt;Thank you for the examples - I really appreciate them. I do recognize that CGI.pm is available to me and that it is supposed to make many tasks easier and more efficient, but I&#039;m an old dog, and that&#039;s a new trick that I&#039;m going to continue to resist using for a while - too many other things to learn...&lt;/p&gt;
&lt;p&gt;I did, however, figure this out.  The book I got the cookie parsing routine out of had a typo.&lt;/p&gt;
&lt;p&gt;Here&#039;s the content of $ENV{HTTP_COOKIE}:&lt;br /&gt;
ID=16bed70d0bc216db0572bce1bf48dcb9; action=main &lt;/p&gt;
&lt;p&gt;So I needed to add a space after the semicolon in my split statement...&lt;br /&gt;
---from---&lt;br /&gt;
my @cookies = split(/;/,$ENV{HTTP_COOKIE});&lt;br /&gt;
---to---&lt;br /&gt;
my @cookies = split(/; /,$ENV{HTTP_COOKIE});&lt;/p&gt;
&lt;p&gt;I can now read multiple cookies.  Thanks again for the help.&lt;/p&gt;
 </description>
     <pubDate>Tue, 04 Feb 2003 15:00:44 +0000</pubDate>
 <dc:creator>critical</dc:creator>
 <guid isPermaLink="false">comment 1124825 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/issue-setting-cookies#comment-1124824</link>
    <description> &lt;p&gt;Let me give you a few more examples.&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt; use CGI;&lt;br /&gt; my $query = CGI-&amp;gt;new();&lt;br /&gt;&lt;br /&gt;sub set_cookie {&lt;br /&gt;&lt;br /&gt; my $cookie = $query-&amp;gt;cookie (&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp; -name =&amp;gt; &amp;#039;mycookie&amp;#039;,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp; -value =&amp;gt; &amp;#039;value&amp;#039;,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp; -expires =&amp;gt; &amp;#039;+1M&amp;#039;,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp; -path =&amp;gt; &amp;#039;/&amp;#039;,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp; -domain =&amp;gt; &amp;#039;mydomain.com&amp;#039;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 	&lt;br /&gt; );&lt;br /&gt;&lt;br /&gt; print $query-&amp;gt;header( -cookie=&amp;gt; $cookie );&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;sub retrieve_cookie {&lt;br /&gt;&lt;br /&gt; my $cookie = $query-&amp;gt;cookie(&amp;#039;mycookie&amp;#039;);&lt;br /&gt;&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;Hope that helps.&lt;/p&gt;
 </description>
     <pubDate>Tue, 04 Feb 2003 14:50:20 +0000</pubDate>
 <dc:creator>Wil</dc:creator>
 <guid isPermaLink="false">comment 1124824 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/issue-setting-cookies#comment-1124823</link>
    <description> &lt;p&gt;CGI.pm comes with Perl. You don&#039;t need to download anything.&lt;/p&gt;
&lt;p&gt;Reading cookies is an absolute walk in the park, too. Try something like:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;my $cookie1 = $query-&amp;gt;cookie(&amp;#039;cookie1);&lt;br /&gt;my $cookie2 = $query-&amp;gt;cookie(&amp;#039;cookie2&amp;#039;);&lt;br /&gt;...&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;Can&#039;t get any easier than that. &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Tue, 04 Feb 2003 14:47:56 +0000</pubDate>
 <dc:creator>Wil</dc:creator>
 <guid isPermaLink="false">comment 1124823 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/issue-setting-cookies#comment-1124821</link>
    <description> &lt;p&gt;Thanks for the advice about using an existing module.  I&#039;m sure that&#039;s the best approach.  Unfortunately I don&#039;t use CGI.pm and would prefer not to download and install any other modules.&lt;/p&gt;
&lt;p&gt;Can anyone help me out with a do-it-yourself reinvent-the-wheel read-more-than-one-cookie code in Perl?&lt;/p&gt;
&lt;p&gt;I can set multiple cookies.  And my code (above) can successfully read the first one.  But it&#039;s not reading in additional cookies after the first.&lt;/p&gt;
&lt;p&gt;TIA.&lt;/p&gt;
 </description>
     <pubDate>Tue, 04 Feb 2003 14:14:25 +0000</pubDate>
 <dc:creator>critical</dc:creator>
 <guid isPermaLink="false">comment 1124821 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/issue-setting-cookies#comment-1124787</link>
    <description> &lt;p&gt;OK. Start off. Please don&#039;t roll your own Cookie parser/set routine. Please consider using CGI.pm or any of the Cookie::, CGI::Cookie, modules on the CPAN.&lt;/p&gt;
&lt;p&gt;Here&#039;s the relevent bit in the CGI.pm docs about cookies. &lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://stein.cshl.org/WWW/software/CGI/#cookies&quot; class=&quot;bb-url&quot;&gt;http://stein.cshl.org/WWW/software/CGI/#cookies&lt;/a&gt;&lt;/p&gt;
 </description>
     <pubDate>Mon, 03 Feb 2003 22:55:09 +0000</pubDate>
 <dc:creator>Wil</dc:creator>
 <guid isPermaLink="false">comment 1124787 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/issue-setting-cookies#comment-1124779</link>
    <description> &lt;p&gt;Nope - that&#039;s not working either...  When I read the cookie, it&#039;s only grabbing the first of the 2 sets... I still need your help...&lt;/p&gt;
&lt;p&gt;	# GET COOKIE CRUMBS&lt;br /&gt;
my %crumbs = &quot;&quot;;&lt;br /&gt;
if ($ENV{HTTP_COOKIE} ne &quot;&quot;) {&lt;br /&gt;
   my @cookies = split(/;/,$ENV{HTTP_COOKIE});&lt;br /&gt;
   foreach my $cookie (@cookies) {&lt;br /&gt;
      my ($name, $value) = split(/=/,$cookie);&lt;br /&gt;
      $crumbs{$name} = $value;&lt;br /&gt;
   } # end for&lt;br /&gt;
} # end if&lt;br /&gt;
&amp;amp;Error(&quot; 1 $crumbs{ID}  2 $crumbs{action}&quot;);&lt;/p&gt;
&lt;p&gt;Result:&lt;br /&gt;
1 9b9df633f4dbb23c5bca988167031ac4&lt;br /&gt;
2&lt;/p&gt;
 </description>
     <pubDate>Mon, 03 Feb 2003 21:20:09 +0000</pubDate>
 <dc:creator>critical</dc:creator>
 <guid isPermaLink="false">comment 1124779 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/issue-setting-cookies#comment-1124777</link>
    <description> &lt;p&gt;I think I solved my own problem.&lt;/p&gt;
&lt;p&gt;I think I need a separate Set_Cookie statement for each key-value pair.  I&#039;m still testing but it looks like that&#039;s what it is.  Duh.&lt;/p&gt;
&lt;p&gt;print &quot;Set-Cookie:ID=$session_id; path=/; expires=Thu, 31-Dec-2003 00:00:00 GMT\n&quot;;&lt;br /&gt;
print &quot;Set-Cookie:action=$action; path=/; expires=Thu, 31-Dec-2003 00:00:00 GMT\n&quot;;&lt;/p&gt;
 </description>
     <pubDate>Mon, 03 Feb 2003 20:53:26 +0000</pubDate>
 <dc:creator>critical</dc:creator>
 <guid isPermaLink="false">comment 1124777 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
