We donÕt want Terri and DianeÕs answers mixed up...so they each need their own separate session object... This method does mor e than just create a session, but the FIRS T time you inv
Trang 1We donÕt want Terri and DianeÕs answers mixed up
so they each need their own separate session object.
Trang 2UHFRJQL]LQJWKH FOLHQW
Trang 3\RXDUHKHUH
+WWS6HVVLRQ,'
+WWS6HVVLRQ,'
Trang 5do anything else!
(This method does mor e than just create a session, but the FIRS T time you invoke it on the r equest, it will cause a cookie t o be sent with the response Now, ther eÕs still not guarantee the cli ent will ACCEPT the cookie but weÕr e getting ahead
of ourselves.)
*HWWLQJWKHVHVVLRQ,'IURPWKH5(48(67
+WWS6HVVLRQVHVVLRQ UHTXHVWJHW6HVVLRQ ,OOK
as SENDING a session ID cooki
e
You never actually SEE the session
ID yourself (although you can ask the session to give it to you).
Trang 6isNew() returns true if the client has not yet resp onded with this session ID.
Trang 7Here we KNOW weÕre making a new session.
Trang 8)FGET3ESSION
Trang 9We add the session ID to the end
of all the URLs in the HTML we send back in the Response.
The session ID comes back as ÒextraÓ info stuck to the end of the Request URL (The semicolon separator is vendor-speciÞ c.)+7735HVSRQVH
+7735HTXHVW
Trang 10#ONTAINERSESSION CAN)LLNEED
85/ UHZULWLQJ
Trang 12DonÕt do this! ItÕs supposed to be a header!
This is right, but you donÕt do it your self. The result of
URL rewriting (you donÕt do this yourself either).
Trang 13\RXDUHKHUH
/M\\QVOZQLWN[M[[QWV[
4HEMINDSESSION
IN MAKINGCOMPUTER
4HEWANT2EMEMBER MECHANISMGONE
YOU
"UTCLIENTTHE
(He wants to conserve space
on his machine for playing
ÒThe SimsÓ with the ÒHot
DateÓ expansion pack.)
Trang 15LPH 6WULQJJHW,G ORQJJHW/DVW$FFHVVHG7
LPH LQWJHW0D[,QDFWLYH,QWHUYDO 6HUYOHW&RQWH[WJHW6HUYOHW&RQWH[W ... class="text_page_counter">Trang 44
FKDSWHU
#HOOSEVALUE
Trang 46 Trang 41Trang 43
\RXDUHKHUH...
/M\\QVOZQLWN[M[[QWV[
4HEMINDSESSION
INMAKINGCOMPUTER
4HEWANT2EMEMBERMECHANISMGONE
YOU
34; UTCLIENTTHE
(He wants to conserve