Message from discussion
Session changes not persistent
Date: Sat, 30 Jun 2012 16:32:47 -0700 (PDT)
From: Ben Corne <ben.co...@gmail.com>
To: nowjs@googlegroups.com
Message-Id: <2d90babb-a3f6-4c83-b28e-c4a4034efeee@googlegroups.com>
Subject: Session changes not persistent
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_775_12917497.1341099167485"
------=_Part_775_12917497.1341099167485
Content-Type: multipart/alternative;
boundary="----=_Part_776_7207907.1341099167486"
------=_Part_776_7207907.1341099167486
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Hi. I'm experimenting with now.js, and sure like the idea.
However I've ran into trouble with session support using express.
This is my program's cflow:
clientside: user visits website
clientside: user clicks guest login
clientside: guest login click triggers now.guestLogin()
serverside: guestLogin creates a new guest user, and finishes login with
finishLogin
serverside: finishLogin assigns the newly created guest user object to
session.user
serverside: finishLogin triggers client's now.loginOk() method
clientside: loginOk is called and a request to a page requiring
session.user is a user.
however the session.user set in finishLogin seems not to be persisted. So I
went digging, logging the session variable when setting it and when
requesting the page requiring to be logged in.
Server console:
$ node app.js
Express server listening on port 80 in development mode
now method session after user assignment =
{ lastAccess: 1341098607952,
cookie:
{ path: '/',
httpOnly: true,
_expires: Sun, 01 Jul 2012 03:23:27 GMT,
originalMaxAge: 14400000 },
user: { guest: true, nickname: 'guest0' } }
express session output =
{ lastAccess: 1341098609861,
cookie:
{ path: '/',
httpOnly: true,
_expires: Sun, 01 Jul 2012 03:23:27 GMT,
originalMaxAge: 14400000 } }
As you can see, the session does contain an actual user after assigning
session.user (now method session output)
but it disappears again when I request a page after this (express session
output).
Any ideas what's wrong here?
Kind regards
Ben
------=_Part_776_7207907.1341099167486
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
<div>Hi. I'm experimenting with now.js, and sure like the idea.</div><div><=
br></div><div>However I've ran into trouble with session support using expr=
ess.<br><br>This is my program's cflow:</div><div><br></div><div>clientside=
: user visits website</div><div>clientside: user clicks guest log=
in</div><div>clientside: guest login click triggers now.guestLogin()</div><=
div>serverside: guestLogin creates a new guest user, and finishes login wit=
h finishLogin</div><div>serverside: finishLogin assigns the newly created g=
uest user object to session.user</div><div>serverside: finishLogin triggers=
client's now.loginOk() method</div><div>clientside: loginOk is called and =
a request to a page requiring session.user is a user.</div><div><br></div><=
div>however the session.user set in finishLogin seems not to be persisted. =
So I went digging, logging the session variable when setting it and when re=
questing the page requiring to be logged in.</div><div><br></div><div>Serve=
r console:</div><div>$ node app.js</div><div>Express server listening on po=
rt 80 in development mode</div><div>now method session after user assignmen=
t =3D</div><div>{ lastAccess: 1341098607952,</div><div> cookie:</div>=
<div> { path: '/',</div><div> httpOnly: true=
,</div><div> _expires: Sun, 01 Jul 2012 03:23:27 GMT,</d=
iv><div> originalMaxAge: 14400000 },</div><div> us=
er: { guest: true, nickname: 'guest0' } }</div><div>express session output =
=3D</div><div>{ lastAccess: 1341098609861,</div><div> cookie:</div><d=
iv> { path: '/',</div><div> httpOnly: true,<=
/div><div> _expires: Sun, 01 Jul 2012 03:23:27 GMT,</div=
><div> originalMaxAge: 14400000 } }</div><div><br></div>=
<div>As you can see, the session does contain an actual user after assignin=
g session.user (now method session output)</div><div>but it disappears agai=
n when I request a page after this (express session output).</div><div><br>=
</div><div>Any ideas what's wrong here?</div><div><br></div><div>Kind regar=
ds</div><div>Ben</div>
------=_Part_776_7207907.1341099167486--
------=_Part_775_12917497.1341099167485--