Re: Manually setting session ids
- From: "Álvaro G. Vicario" <webmasterNOSPAMTHANKS@xxxxxxxxxxxxxx>
- Date: Mon, 29 Sep 2008 20:53:58 +0200
*** Hugh Oxford escribió/wrote (Mon, 29 Sep 2008 18:33:09 +0100):
I am writing some server to server software that needs to maintain state.
When I say server to server I mean that the client is not a browser, it
is another PHP server (as if that wasn't obvious).
The word "server" has lots of meanings. What do you mean exactly? If you
are connecting to a remote server using HTTP, it doesn't matter who you
are: the mechanism is exactly the same.
This is the server (pseudocode). Forget the transport mechanism, imagine
that any function can be called remotely.
You are making a rather curious assumption but...
The problem seems to be that session_start on the server side is called
at the top of the script, and there is no way to change the session_id
midstream.
.... this works for me:
<?php
session_id('A');
session_start();
$_SESSION['who_am_i'] = 'I am session A';
session_write_close();
session_id('B');
session_start();
$_SESSION['who_am_i'] = 'I am session B';
session_write_close();
session_id('A');
session_start();
echo $_SESSION['who_am_i'] . "\n";
session_write_close();
session_id('B');
session_start();
echo $_SESSION['who_am_i'] . "\n";
session_write_close();
?>
You need to set session.use_cookies to 0 in your php.ini (or use @ to hide
warnings).
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor en cubitos: http://www.demogracia.com
--
.
- References:
- Manually setting session ids
- From: Hugh Oxford
- Manually setting session ids
- Prev by Date: Re: Can't addFile() in SimpleTest Test Suite
- Next by Date: Re: accents being replaced with garbage in text fields on forms
- Previous by thread: Manually setting session ids
- Next by thread: Re: Manually setting session ids
- Index(es):
Relevant Pages
|