HTTP::Cookies save() not Saving Temporary Cookies

This section provides a tutorial example showing that the save() method in the HTTP::Cookies class does not save any temporary (non-persistent) cookies to the cookie jar file.

In the previous tutorial, we have tested on persistent cookies, which are correctly saved into the "HTTP-Cookies.jar" file.

Now let's see how behaves on temporary (non-persistent) cookies. To do this test, we my CGI script running on my local Apache Web server as described in previous tutorials.

   GET http://localhost/

GET http://localhost/
User-Agent: Mozilla/5.0 (Windows NT 6.1)

HTTP/1.1 200 OK
Connection: close
Server: Apache/2.2.25 (Win32)
Content-Type: text/html; charset=ISO-8859-1
Client-Transfer-Encoding: chunked
Set-Cookie: Chocolate_1=Another%20chocolate%20cookie%20for%20you%2...
Set-Cookie: Sugar_2=Another%20sugar%20cookie%20for%20you%21; path=/

<html xmlns="" lang="en-US" xml:lang=...
<meta http-equiv="Content-Type" content="text/html; charset=iso-8...
<pre>0 Cookies received from request:

herong> more HTTP-Cookies.jar

Set-Cookie3: datr=df0dU_W0r6vNIWj_NgpYQMJ7; path="/"; domain=.face...
Set-Cookie3: fr=0oswe6EQT4vYQsVEs.AWXgFm5hU3wMtefwkipG9OoNw3A.BTEl...
Set-Cookie3: lu=SgFEbQxflkf9cYQqNmEjSYmw; path="/"; domain=.facebo...
Set-Cookie3: NID="67=v4hLLg1a_TYSA0jgDZmyiEFmp2r3qWujpGhCRAx9by8hS...
Set-Cookie3: PREF="ID=39f3c35845eeda94:U=5282f19f1a13190a:FF=0:TM=...

Based on the output of the first command, 2 cookies "Chocolate_1" and "Sugar_2" were received by the client script.

But based on the output of the second command, these 2 cookies were not saved to the "HTTP-Cookies.jar".

This indicates that the save() method in the HTTP::Cookies class does not save any temporary cookies to the cookie jar file.

If save() method is not saving temporary cookie to the cookie jar file, we will not be able to use the script to send multiple requests that shares temporary cookies.

See the next tutorial on to how enhance the script.

Table of Contents

 About This Book

 Perl on Linux Systems

 ActivePerl on Windows Systems

 Data Types: Values and Variables

 Expressions, Operations and Simple Statements

 User Defined Subroutines

 Perl Built-in Debugger

 Name Spaces and Perl Module Files

 Symbolic (or Soft) References

 Hard References - Addresses of Memory Objects

 Objects (or References) and Classes (or Packages)

 Typeglob and Importing Identifiers from Other Packages

 String Built-in Functions and Performance

 File Handles and Data Input/Output

 Open Files in Binary Mode

 Open Directories and Read File Names

 File System Functions and Operations

 Image and Picture Processing

 Using DBM Database Files

 Using MySQL Database Server

 Socket Communication Over the Internet

 XML::Simple Module - XML Parser and Generator

 XML Communication Model

 SOAP::Lite - SOAP Server-Client Communication Module

 Perl Programs as IIS Server CGI Scripts

 CGI (Common Gateway Interface)

 XML-RPC - Remote Procedure Call with XML and HTTP

 RPC::XML - Perl Implementation of XML-RPC

 Integrating Perl with Apache Web Server Module for Building Web Pages

LWP::UserAgent and Web Site Testing

 What Is LWP::UserAgent?

 What Is HTTP::Response?

 What Is HTTP::Request? - Sending a GET Request - Following HTTP Redirects

 http-equiv="Refresh" Meta Tag not Followed - Posting Form Data

 post() Method not Following Redirect Location - Posting with Redirects

 What Is HTTP::Cookies? - GET, POST and Cookies - Login to

HTTP::Cookies save() not Saving Temporary Cookies - Sending Request with Cookies

 Converting Perl Script to Executable Binary

 Managing Perl Engine and Modules on macOS

 Archived Tutorials


 Full Version in PDF/EPUB