tags:

views:

409

answers:

2

Using Snoopy I make a request, but it seems that a different SESSION is used for the POST? When I echo the results of the request the SESSION is set but after clicking any link the page returns to a non SESSION-set state.

Currently i'm using v.little code to make the request

$dashboard = new Snoopy;

$dashboard->referer = "URL";
$dashboard->httpmethod = "POST";
$dashboard->submit("URL", $_POST);

echo $dashboard->results;

I don't have the ability to use cURL as I have no control over the server.

I have a feeling its due to Snoopy making a new SESSION_ID for the HTTP POST? i've seen bits and bobs on the net but nothing concrete on how to maintain SESSION between these requests?

Cheers, MiG

A: 

You need to call the session_start function in submitting url file.

so , session can maintain as you want.

pavun_cool
A: 

If you don't pass the SESSIONID to the page you are calling with Snoopy (this would be true for any other way of doing that HTTP request), then, when generating that page, PHP will :

  • try to start a session
  • as no session id has been received, an new session will be started
  • which will be distinct from the one used in your first script.


If you want both scripts to share the same session, you will at least have to pass the session id to the second script -- which is generally done using a cookie (see the cookies you have for your site, in your browser).

Basically : the script that's called via Snoopy has to receive the session id, the same way the script that's called by your browser receives it.

Pascal MARTIN
How would I go about doing this? could you provide a example? this PHP stuff evades me :)
MiG
I don't really know, with Snoopy -- but looking at its code, it seems there is a `$cookies` property ; you could use that to set a cookie called `PHPSESSID` *(or the name that's required on your system -- see http://fr.php.net/manual/en/session.configuration.php#ini.session.name )*, that has the same value as your current `$_COOKIE['PHPSESSID']`
Pascal MARTIN