cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

JSESSIONID cookie between 2 pages

From: Travis Staloch <twostepted_at_yahoo.com>
Date: Sun, 1 Aug 2004 17:56:51 -0700 (PDT)

I'm trying to get a JSESSIONID cookie and use it to
get some arc info from the URL's below. Here is my
curl info: libcurl/7.10.5 OpenSSL/0.9.7b zlib/1.1.4

I've been trying alot of different methods including
using a cookiefile and cookiejar. But I can't seem to
get these to work. I keep getting the message:
Session has expired. I don't know if I'm passing the
cookie correctly or what else I could do to get this
working.

Also, it would help if I could figure out how to view
the header I'm sending with curl, not just the one
received.

Any help is greatly appreciated.

--Travis

<?php
$URL1="http://arcweb.esri.com/livesamples/v2/addressfinder/index.jsp";
$URL2="http://arcweb.esri.com/livesamples/servlet/GN_GeoServices_V2";

// open URL1 to get JSESSIONID
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return
into a variable
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_URL,"$URL1");
$page = curl_exec ($ch);
// get cookies from URL1
preg_match("/Set-cookie: (.*)\n/iU", $page, $matches);
$cookie = trim(substr($matches[1], strpos($matches[1],
':')));

$cookie = implode(';', $cookie);
$cookie = substr($cookie, 1);*/
echo $cookie;
// echoes:
JSESSIONID=arcweb.esri.com-428%253A410d8a07%253A2aa1f89d3d2b803b;path=/livesamples

// open URL2, include postdata and JSESSIONID cookie.
curl_setopt($ch, CURLOPT_URL,"$URL2");
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"countryRadio=usa&datasourcename=GDT.Address.US&address=322+N.+Pacific+St.&inter=&city=&state=&zipcode=98926&country=US&serviceName=AddressFinder&routePointFor=&title=Address+Finder&countryname=us&datasource=GDT.Address.US&message=&x=45&y=7");
curl_setopt($ch, CURLOPT_HEADER, 1);
// view output
echo curl_exec ($ch);
?>

                
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail
Received on 2004-08-02