<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://community.activestate.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>ActiveState Community Site - Set-Cookie header - Comments</title>
 <link>http://community.activestate.com/forum-topic/set-cookie-header</link>
 <description>Comments for &quot;Set-Cookie header&quot;</description>
 <language>en</language>
<item>
 <title>Of course this must be one</title>
 <link>http://community.activestate.com/forum-topic/set-cookie-header#comment-3628</link>
 <description>&lt;p&gt;Of course this must be one script (unless you save your cookies to file in one script and load them in another). See &lt;strong&gt;$cookie_jar-&amp;gt;save()&lt;/strong&gt; and &lt;strong&gt;$cookie_jar-&amp;gt;load()&lt;/strong&gt; in &lt;code class=&quot;geshifilter&quot;&gt;HTTP::Cookies&lt;/code&gt;.&lt;/p&gt;
</description>
 <pubDate>Tue, 04 Dec 2007 01:20:30 -0800</pubDate>
 <dc:creator>gangabass</dc:creator>
 <guid isPermaLink="false">comment 3628 at http://community.activestate.com</guid>
</item>
<item>
 <title>I tried the URL calls from</title>
 <link>http://community.activestate.com/forum-topic/set-cookie-header#comment-3627</link>
 <description>&lt;p&gt;I tried the URL calls from separate perl scripts earlier. Probebly thats why it didn&#039;t work so I guess it will work if I did the whole thing in one go. Will check using plain LWP::UserAgent first. Thanks&lt;/p&gt;
</description>
 <pubDate>Mon, 03 Dec 2007 23:58:46 -0800</pubDate>
 <dc:creator>shamly</dc:creator>
 <guid isPermaLink="false">comment 3627 at http://community.activestate.com</guid>
</item>
<item>
 <title>Life is short so &quot;use</title>
 <link>http://community.activestate.com/forum-topic/set-cookie-header#comment-3626</link>
 <description>&lt;p&gt;Life is short so &quot;use WWW::Mechanize&quot;.&lt;br /&gt;
You only need to make first login request after that your cookies will be  automatically set.&lt;br /&gt;
By the way you can make the same with plain LWP::UserAgent (so you don&#039;t need HTTP::Request::Common and HTTP::Cookies). Just use same $ua for both requests.&lt;/p&gt;
</description>
 <pubDate>Mon, 03 Dec 2007 17:12:06 -0800</pubDate>
 <dc:creator>gangabass</dc:creator>
 <guid isPermaLink="false">comment 3626 at http://community.activestate.com</guid>
</item>
<item>
 <title>Set-Cookie header</title>
 <link>http://community.activestate.com/forum-topic/set-cookie-header</link>
 <description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;   I have an application that needs to send a HTTP request to a web server. The first request is a login request where all the params are sent via GET method. The reply to this request will be a session ID. Next time i make a request to this URL i need to set this session id in Set-Cookie header or else  an error msg will be returned. I have tried doing it in the following manner .. &lt;/p&gt;
&lt;p&gt;use HTTP::Request::Common qw(GET);&lt;br /&gt;
use LWP::UserAgent;&lt;br /&gt;
use HTTP::Cookies;&lt;/p&gt;
&lt;p&gt;my $ua = LWP::UserAgent-&amp;gt;new;&lt;br /&gt;
$ua-&amp;gt;timeout(10);&lt;/p&gt;
&lt;p&gt;my $cookie_jar = HTTP::Cookies-&amp;gt;new;&lt;br /&gt;
my $req = HTTP::Request-&amp;gt;new(GET =&amp;gt; &quot;http://remote_ip:port/file_name.jsp?get_bal=shamly&quot;);&lt;/p&gt;
&lt;p&gt;$cookie_jar-&amp;gt;set_cookie(&quot;JSESSIONID=FFX1A19D2699C0099&quot;);&lt;/p&gt;
&lt;p&gt;$ua-&amp;gt;cookie_jar($cookie_jar);&lt;/p&gt;
&lt;p&gt;my $res = $ua-&amp;gt;request($req);&lt;/p&gt;
&lt;p&gt;if ($res-&amp;gt;is_success) {&lt;br /&gt;
#    print $res-&amp;gt;decoded_content;&lt;br /&gt;
    print $res-&amp;gt;as_string;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
    print &quot;Error: &quot; . $res-&amp;gt;status_line . &quot;\n&quot;;&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;The request seems to fail as an error code is returned. Another probs is that I have no access on the server side. At present I am using a php file using curl functions. &lt;/p&gt;
&lt;p&gt;curl_setopt ($ch, CURLOPT_COOKIE, &quot;JSESSIONID=FFX1A19D2699C0099&quot;);&lt;/p&gt;
&lt;p&gt;I would like to be able to implement this in perl itself. Any help please ...&lt;/p&gt;
</description>
 <comments>http://community.activestate.com/forum-topic/set-cookie-header#comments</comments>
 <category domain="http://community.activestate.com/forums/perl-discussion-0">Perl discussion</category>
 <category domain="http://community.activestate.com/os/red-hat-fedora-core">Red Hat / Fedora Core</category>
 <pubDate>Mon, 03 Dec 2007 04:10:46 -0800</pubDate>
 <dc:creator>shamly</dc:creator>
 <guid isPermaLink="false">1694 at http://community.activestate.com</guid>
</item>
</channel>
</rss>
