Re: Manually setting session ids
- From: "C. (http://symcbean.blogspot.com/)" <colin.mckinnon@xxxxxxxxx>
- Date: Tue, 30 Sep 2008 05:31:58 -0700 (PDT)
On 29 Sep, 18:33, Hugh Oxford <ares...@xxxxxxx> wrote:
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 obvious way to do this is to use the session ID. The problem is, how
to first of all generate a session ID and then send back a session ID to
reload a session.
Perhaps my understanding of sessions is too limited, but I can't see the
wood for the trees at the moment. Maybe it's obvious and I can't see it.
This is the server (pseudocode). Forget the transport mechanism, imagine
that any function can be called remotely.
<?php
session_start();
function GetSessionID()
{
return session_id();
}
function SetSessionID($session_id)
{
session_id($session_id);
}
function SetVar($var, $val)
{
$_SESSION[$var] = $val;
}
function GetVar($var)
{
return $_SESSION[$var];
}
?>
now, on the client side, the idea is to do something like this
$sid = $client->GetSessionId();
$client->SetSessionId($sid);
$client->SetVar('foo', 'bar');
echo $client->GetVar('foo'); //returns 'bar'
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.
Even if I could change the session_id, would I get back the data I had
already set?
Does anyone have any thoughts. I'm going mad.
You're trying to make the session model for browser wielding users fit
a server-to-server model. Start again with a blank bit of paper.
We can't advise further without knowing a lot more about the
interchange - how does security figure? Will there be multiple
clients? "Forget the transport mechanism" - do you mean we should
assume that it's transactionally secure or that this doesn't matter?
Does it have to run synchronously or asynchronously? Are you writing
the code at both ends?
C.
.
- References:
- Manually setting session ids
- From: Hugh Oxford
- Manually setting session ids
- Prev by Date: Re: Rewrite Module Session problem
- Next by Date: Re: Manually setting session ids
- Previous by thread: Re: Manually setting session ids
- Next by thread: Re: Manually setting session ids
- Index(es):
Relevant Pages
|