PseudoZen Posted February 23, 2007 Share Posted February 23, 2007 Cookie handling in snoopy is giving me fits, and I'm not sure whether it's related to the remote website being on an IIS server or not. Here are the headers from my initial $snoopy->fetch : 0 ---> HTTP/1.1 200 OK 1 ---> Connection: close 2 ---> Date: Fri, 23 Feb 2007 02:16:58 GMT 3 ---> Server: Microsoft-IIS/6.0 4 ---> X-Powered-By: ASP.NET 5 ---> X-AspNet-Version: 1.1.4322 6 ---> Set-Cookie: ASP.NET_SessionId=stkcoqjepgfb4355kvxms5ej; path=/ 7 ---> Set-Cookie: OnCoreWeb=AutoLoadImages=-1&ImageViewer=2&DefaultNumberOfRows=15; expires=Sat, 23-Feb-2008 02:16:58 GMT; path=/ 8 ---> Set-Cookie: OnCoreWebAuthenticated=Authenticated=0&AgentKey=-1&CacheKey=76618571&LastUrl=http://198.185.140.50/oncoreweb/settings.aspx; expires=Fri, 23-Feb-2007 12:16:58 GMT; path=/ 9 ---> Cache-Control: private 10 ---> Content-Type: text/html; charset=utf-8 11 ---> Content-Length: 38389 I need to pass the two cookies highlighted above with each subsequent Snoopy session. So I extract the cookies with this code: // grab the headers $headers = $prep_cookies->headers; while(list($key,$val) = each($headers)) { echo $key.' ---> ' . $val.'<br>'; // If this iteration is the SessionID cookie, grab that value for later use if (preg_match("/ASP.NET_SessionId=(.*?)$/i", $val, $ubid)) { // send this cookie to the next session $sessionID=$ubid[1]; } } Then, in the next Snoopy request, I pass these cookies using: $go = new Snoopy; $go->cookie["ASP.NET_SessionId"]=$sessionID; $go->cookie["OnCoreWeb"]="AutoLoadImages=-1&ImageViewer=1&DefaultNumberOfRows=500&DisablePDFStreaming=True"; ... Here are the headers from the 2nd request: 0 ---> HTTP/1.1 200 OK 1 ---> Connection: close 2 ---> Date: Fri, 23 Feb 2007 02:16:58 GMT 3 ---> Server: Microsoft-IIS/6.0 4 ---> X-Powered-By: ASP.NET 5 ---> X-AspNet-Version: 1.1.4322 6 ---> Set-Cookie: ASP.NET_SessionId=stkcoqjepgfb4355kvxms5ej; path=/ 7 ---> Set-Cookie: OnCoreWeb=AutoLoadImages=-1&ImageViewer=2&DefaultNumberOfRows=15; expires=Sat, 23-Feb-2008 02:16:58 GMT; path=/ 8 ---> Set-Cookie: OnCoreWebAuthenticated=Authenticated=0&AgentKey=-1&CacheKey=76618571&LastUrl=http://198.185.140.50/oncoreweb/settings.aspx; expires=Fri, 23-Feb-2007 12:16:58 GMT; path=/ 9 ---> Cache-Control: private 10 ---> Content-Type: text/html; charset=utf-8 11 ---> Content-Length: 38389 It appears that the OnCoreWeb cookie was passed successfully, but it wasn't. The target website automatically creates the OnCoreWeb cookie if one isn't passed to it, and you can tell you're looking at the default cookie because the values are not what I set in the previous cookie but, rather, the default values. In particular, ImageViewer=1 and DefaultNumberOfRows=15;. In other words, if I didn't pass any OnCoreWeb cookie to $go, I'd still get the default OnCoreWeb cookie shown in the last example. My problem is this: I can't tell whether my cookie is failing to send properly, or whether it's just that the ASP application I'm polling has a mechanism to detect that it didn't set that cookie and is returning their default settings cookie instead. I did notice that there's a new in the 2nd session: OnCoreWebAuthenticated. I've tried passing that cookie as well, but the results are the same. Any suggestions or experience with snoopy or curl on IIS? Or am I looking at more of an issue with the application logic of the target website keeping me from setting that cookie? Link to comment https://forums.phpfreaks.com/topic/39735-snoopy-sessions/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.