Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 29th, 2005, 12:56 AM
Authorized User
 
Join Date: Dec 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Server acting as browser - handling cookies?

I need to have my Apache/PHP 4.3.0 server act as a client browser and navigate to a restricted site that uses session cookies. The PHP script needs to:

1. Login:
    $url_login = 'https://www.secure.com/scripts/cgi.exe/uv.w?request=login&login=myaccount&password=mypass word';
    copy($url_login,$response_file);

2. Gather data and process:
    $url_data = 'https://www.secure.com/scripts/cgi.exe/uv.w?request=getdata&index=3';
    copy($url_data,$data_file);
    process_data($data_file);

3. Logout:
    $url_logout = 'http://www.secure.com/bye.asp?request=logout';
    copy($url_logout, $response_file);

Steps 1 and 3 work fine since they don't require session cookies. Step 2 fails since session cookie info is not stored by step 1 and subsequently sent in the HTTP header of the 'copy' function in step 2.

Questions:

1. How can step 1 get the HTTP header cookie information from the 'copy' request? (or suggested equivalent functionality).

2. How can step 2 supply the HTTP header cookie information in the 'copy' request? (or suggested equivalent functionality).

TNX for your help.

Philibuster
__________________
Philibuster
 
Old August 15th, 2006, 09:39 PM
Authorized User
 
Join Date: Dec 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The best solution to this requirement appears to be LibCurl. It will handle most of the HTTP functionality including cookies.

Philibuster





Similar Threads
Thread Thread Starter Forum Replies Last Post
(Chap 2) problem with cookies using safari browser Stephen Liggett BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 April 20th, 2006 11:25 AM
Handling Cookies rit01 ASP.NET 2.0 Basics 6 March 22nd, 2006 04:21 PM
handling script errors using vb web browser state Beginning VB 6 3 January 19th, 2006 09:01 AM
SQL Server sync with net server and browser server ne SQL Server DTS 0 June 13th, 2005 06:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.