[UPHPU] session not working in page read with fsockopen
Wade Preston Shearer
lists at wadeshearer.com
Sat Oct 4 17:43:13 MDT 2008
On 3 Oct 2008, at 20:26, Daniel C. wrote:
> On Fri, Oct 3, 2008 at 10:02 PM, Wade Preston Shearer wrote:
>
>> I have a script that is reading another script via fsockopen. The
>> second
>> script continues the user's session and echos out a variable in the
>> session.
>> When I load this second script in a web browser it correctly echo's
>> out the
>> variable but when fsockopen reads it it echos out nothing. I think
>> that this
>> is because fsockopen isn't providing all of the functionality that
>> a browser
>> does—namely, accepting cookies—and therefor now adequately carrying
>> the
>> session. Does anyone have any idea on how I could make this work?
>
> www.php.net/curl
>
> Look at the curl_setopt function for info about how to set the "cookie
> jar" for your curl sessions. Should do exactly what you want.
Thanks, Daniel. I got it working so that the session is working when
the script is called by fsockopen [1]. Now, I have come across another
problem however. I know that second script can read the session
because if I write the variable out to a file or mail() it to myself,
it's there. If I try to echo it out however, I get nothing. I have
narrowed it down to session_start(). If I remove that and echo
something out (a hard-coded test value), it works; if it's there
however, fsockopen reads nothing. So, it appears that calling
session_start() in a script being read by fsockopen kills all content
being outputted. I have tried several different output buffer start/
finish/flush/clean combinations with no changes.
Anyone know why this isn't working or how to get around it?
[1] I did not use curl however since the first script is part of an
application and I didn't want to hack it. The way I got it to work was
by passing the session ID in the URL and setting the session to not
use cookies for that script.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2425 bytes
Desc: not available
Url : http://uphpu.org/pipermail/uphpu/attachments/20081004/6491b480/smime.bin
More information about the UPHPU
mailing list