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

curl-and-php

RE: Maintining a session

From: Lee French <lee.french_at_isev.co.uk>
Date: Thu, 8 May 2008 11:00:53 +0100

Thanks again, I managed to parse the session id from the file and now have
the code shown below however I still do not seem to maintain the session
however a previous non curl session seems to be present which I just cannot
explain. I just wanted to double check that there was nothing glaringly
obvious with the code below since it all looks like it should be working.
Many thanks.

 

<?

$ch = curl_init();

$loc="http://www.website.co.uk/index.php?action=showbasket&_prodid=".$_POST[
'panel_select']."&_qty=".$_POST['panelqty'];

curl_setopt($ch, CURLOPT_URL, $loc);

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch,CURLOPT_FOLLOWLOCATION,0);

curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/websitecookie");

curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/websitecookie");

curl_exec($ch);

curl_close($ch);

 

$dd=file('/tmp/websitecookie');

$expHd=explode("%09",urlencode($dd[4]));

$expHd[6]=urldecode(ereg_replace("%0A","",$expHd[6]));

$val=$expHd[6];

 

header("Set-Cookie: PHPSESSID=$val; path=/");

header('location: http://www.website.co.uk/index.php?action=showbasket');

?>

 

 

 

Kind Regards,

 

Lee French // iSev Limited // website design - website applications -
website hosting

 T. 08700 347 913 // M. 07946 586 598 // E. <mailto:lee.french_at_isev.co.uk>
lee.french@isev.co.uk // W. <http://www.isev.co.uk/> www.isev.co.uk

 

Would you like to see our work? <http://www.isev.co.uk/web-design>
www.isev.co.uk/web-design

 

From: curl-and-php-bounces_at_cool.haxx.se
[mailto:curl-and-php-bounces_at_cool.haxx.se] On Behalf Of Stephen Pynenburg
Sent: 08 May 2008 03:29
To: curl with PHP
Subject: Re: Maintining a session

 

No, sorry, I haven't got anything like that - but generally, you'd have to
parse your cookie.txt file (somehow) then do:

header("Set-Cookie: $parsed_cookie1=$parsed_cookie_value_1...");
header("Location: http://www/page.php");

-Stephen

2008/5/7 Lee French <lee.french_at_isev.co.uk>:

Many thanks for this, do you happen to have an example of sending the cookie
session via header prior to the redirect ? Cheers.

 

Kind Regards,

 

Lee French // iSev Limited // website design - website applications -
website hosting

 T. 08700 347 913 // M. 07946 586 598 // E. <mailto:lee.french_at_isev.co.uk>
lee.french@isev.co.uk // W. <http://www.isev.co.uk/> www.isev.co.uk

 

Would you like to see our work? <http://www.isev.co.uk/web-design>
www.isev.co.uk/web-design

 

From: curl-and-php-bounces_at_cool.haxx.se
[mailto:curl-and-php-bounces_at_cool.haxx.se] On Behalf Of Stephen Pynenburg
Sent: 07 May 2008 21:15
To: curl with PHP
Subject: Re: Maintining a session

 

cURL session and cookies are always separate from the browser's. You'll have
to send a Set-Cookie header along with the redirect header, using the
cookies that you have saved to /tmp/mycookie .

-Stephen

2008/5/7 Lee French <lee.french_at_isev.co.uk>:

Dear Group,

 

I am in the process of writing a php script that adds items to a shopping
cart on another website and then performs a header redirect to the cart page
on the other website. However, at the moment my curl session is not
maintained on the redirect session (which I expected to be honest). Is it
possible for me to maintain the session used during the curl interactivity?
This is an example of the code I am using :

 

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,
"http://www.cartwebsite.co.uk/index.php?action=showbasket
<http://www.cartwebsite.co.uk/index.php?action=showbasket&_prodid=>
&_prodid=".$_POST['panel_select']."&_qty=".$_POST['panelqty']);

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch,CURLOPT_FOLLOWLOCATION,0);

curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/mycookie");

curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/mycookie");

curl_exec($ch);

curl_close($ch);

 

header('location:
http://www.cartwebsite.co.uk/index.php?action=showbasket');

 

If I set RETURNTRANSFER to be 0 the session is maintained of course and
content echoes however I wish to allow users to continue on the redirect
website with their cart items intact. I hope this makes sense and any help
you can give me would be great. Many thanks.

 

Kind Regards,

 

Lee French // iSev Limited // website design - website applications -
website hosting

 T. 08700 347 913 // M. 07946 586 598 // E. <mailto:lee.french_at_isev.co.uk>
lee.french@isev.co.uk // W. <http://www.isev.co.uk/> www.isev.co.uk

 

Would you like to see our work? <http://www.isev.co.uk/web-design>
www.isev.co.uk/web-design

 

iSev Limited, e-Innovation Centre SE119, Shifnal Road, Priorslee, Telford,
TF2 9FT

 

 

----------------------------------------------------------------------------
--------------

This email and its attachments may be confidential and are intended solely
for the use of the individual to whom it is addressed. Any views or opinions
expressed are solely those of the author and do not necessarily represent
those of "iSev Limited".

 

If you are not the intended recipient of this email and its attachments, you
must take no action based upon them, nor must you copy or show them to
anyone. Although we operate anti-virus programmes, we cannot guarantee that
this email and any files transmitted with it are virus free and we cannot
accept liability for any damage sustained as a result of the software
viruses.

 

Please contact the sender if you believe you have received this email in
error. For more information on iSev Limited, visit our website at:
<http://www.220i.co.uk/> http://www.isev.co.uk

 

Registered in England and Wales - Company Number: 6553217. Registered
Offices: iSev Limited, e-Innovation Centre SE119, Shifnal Road, Priorslee,
Telford, TF2 9FT

 

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

 

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

 

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-05-08