independent session data for multiple browser windows
independent session data for multiple browser windows
am 16.02.2008 00:00:36 von chas
--Apple-Mail-5--676546854
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed
Greetings,
I have a nearly-completed accounts/billing database using PHP and
MySQL, and was just informed that users will want to access the
database via multiple windows in one browser on the same machine, so
I'm looking for a way to have each browser window have its own set of
session data.
I was initially using cookies, so I switched to propagating the
session name via the URL, and had each window using a unique session
name, but the DATA from each named session was written to the same
file on disk (/private/var/tmp/whatever).
I noticed that the session data file name included the session id, so
I tried propagating the session id in the URL, and setting the
session id right before session_start() -- that resulted in two data
files on disk, but one session would occasionally write to the other
session's data file. At this point, this is the code I'm trying:
if (!array_key_exists('SESSION_ID', $_REQUEST)) {
$_REQUEST['SESSION_ID'] = 'SESS'.uniqid('');
}
session_name($_REQUEST['SESSION_ID']);
session_id($_REQUEST['SESSION_ID']);
session_start();
output_add_rewrite_var('SESSION_ID',$_REQUEST['SESSION_ID']) ;
In php.ini, I now have:
session.use_cookies = 0
session.use_only_cookies = 0
session.auto_start = 0
Also, I'm on Mac OS X Tiger, and everyone's using Safari. PHP
5.0.24a, MySQL 4.1.22
Any suggestions on how to have unique session data for multiple
windows in the same browser on the same machine? Seems like it must
be doable, but I haven't figured it out yet. Thanks to whomever can
help.
Charles Whitaker
Technical Staff
Open Door Networks
--Apple-Mail-5--676546854--
RE: independent session data for multiple browser windows
am 16.02.2008 02:08:12 von Bastien Koert
--_36a219d4-18c1-404d-8a1c-ef6384ed78fa_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
That just sounds like such recipe for disaster. What about running multiple=
divs with each data set in that 'window'? Then you could pass each dataset=
s relevant ids along to keep thing separate...
=20
Another option could to create multiple [i]frames and do the same thing?
=20
Bastien> To: php-db@lists.php.net> From: chas@opendoor.com> Date: Fri, 15 F=
eb 2008 15:00:36 -0800> Subject: [PHP-DB] independent session data for mult=
iple browser windows> > Greetings,> > I have a nearly-completed accounts/bi=
lling database using PHP and > MySQL, and was just informed that users will=
want to access the > database via multiple windows in one browser on the s=
ame machine, so > I'm looking for a way to have each browser window have it=
s own set of > session data.> > I was initially using cookies, so I switche=
d to propagating the > session name via the URL, and had each window using =
a unique session > name, but the DATA from each named session was written t=
o the same > file on disk (/private/var/tmp/whatever).> > I noticed that th=
e session data file name included the session id, so > I tried propagating =
the session id in the URL, and setting the > session id right before sessio=
n_start() -- that resulted in two data > files on disk, but one session wou=
ld occasionally write to the other > session's data file. At this point, th=
is is the code I'm trying:> > if (!array_key_exists('SESSION_ID', $_REQUEST=
)) {> $_REQUEST['SESSION_ID'] =3D 'SESS'.uniqid('');> }> session_name($_REQ=
UEST['SESSION_ID']);> session_id($_REQUEST['SESSION_ID']);> session_start()=
;> output_add_rewrite_var('SESSION_ID',$_REQUEST['SESSION_ID']) ;> > In php.=
ini, I now have:> session.use_cookies =3D 0> session.use_only_cookies =3D 0=
> session.auto_start =3D 0> > Also, I'm on Mac OS X Tiger, and everyone's u=
sing Safari. PHP > 5.0.24a, MySQL 4.1.22> > Any suggestions on how to have =
unique session data for multiple > windows in the same browser on the same =
machine? Seems like it must > be doable, but I haven't figured it out yet. =
Thanks to whomever can > help.> > Charles Whitaker> Technical Staff> Open D=
oor Networks>=20
____________________________________________________________ _____
--_36a219d4-18c1-404d-8a1c-ef6384ed78fa_--
Re: independent session data for multiple browser windows
am 16.02.2008 10:31:02 von lists.zxinn
Charles Whitaker wrote:
> Greetings,
>
> I have a nearly-completed accounts/billing database using PHP and
> MySQL, and was just informed that users will want to access the
> database via multiple windows in one browser on the same machine, so
> I'm looking for a way to have each browser window have its own set of
> session data.
>
> I was initially using cookies, so I switched to propagating the
> session name via the URL, and had each window using a unique session
> name, but the DATA from each named session was written to the same
> file on disk (/private/var/tmp/whatever).
>
> I noticed that the session data file name included the session id, so
> I tried propagating the session id in the URL, and setting the session
> id right before session_start() -- that resulted in two data files on
> disk, but one session would occasionally write to the other session's
> data file. At this point, this is the code I'm trying:
>
> if (!array_key_exists('SESSION_ID', $_REQUEST)) {
> $_REQUEST['SESSION_ID'] = 'SESS'.uniqid('');
> }
> session_name($_REQUEST['SESSION_ID']);
> session_id($_REQUEST['SESSION_ID']);
> session_start();
> output_add_rewrite_var('SESSION_ID',$_REQUEST['SESSION_ID']) ;
>
> In php.ini, I now have:
> session.use_cookies = 0
> session.use_only_cookies = 0
> session.auto_start = 0
>
> Also, I'm on Mac OS X Tiger, and everyone's using Safari. PHP 5.0.24a,
> MySQL 4.1.22
>
> Any suggestions on how to have unique session data for multiple
> windows in the same browser on the same machine? Seems like it must be
> doable, but I haven't figured it out yet. Thanks to whomever can help.
>
> Charles Whitaker
> Technical Staff
> Open Door Networks
>
>
As far as I know, the only way for this to work reliably is if your
users can manually choose to open a new "session" in a new window/tab.
Is this the way you want it to work? Because you can't reliably stop
them from having the same session in multiple windows if they would so
choose.
On the other hand, why would you require multiple sessions if they are
to work against the same database? Will they be using different user
accounts to access it simultaneously, or some administration user with
authorization proxy to use regular accounts?
What kind of information stored in the session would require them to use
different sessions for different tabs? If you give us a hint, we might
be better able to help.
/Tobias
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: independent session data for multiple browser windows
am 20.02.2008 19:57:47 von chas
--Apple-Mail-1--259115855
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=ISO-8859-1;
delsp=yes;
format=flowed
On Feb 16, 2008, at 1:31 AM, Tobias Franz=E9n wrote:
> Charles Whitaker wrote:
>> Greetings,
>>
>> I have a nearly-completed accounts/billing database using PHP and =20
>> MySQL, and was just informed that users will want to access the =20
>> database via multiple windows in one browser on the same machine, =20
>> so I'm looking for a way to have each browser window have its own =20
>> set of session data.
>>
> As far as I know, the only way for this to work reliably is if your =20=
> users can manually choose to open a new "session" in a new window/=20
> tab. Is this the way you want it to work? Because you can't =20
> reliably stop them from having the same session in multiple windows =20=
> if they would so choose.
Tobias,
Thanks for the reply. With one window in Safari open, and accessing =20
the database, they just want to create a new window ("New Window" in =20
Safari's File menu) and access the database from that window as well.
> On the other hand, why would you require multiple sessions if they =20
> are to work against the same database?
> ...
> What kind of information stored in the session would require them =20
> to use different sessions for different tabs? If you give us a =20
> hint, we might be better able to help.
They'll be accessing different account records in different windows. =20
I keep track of the current account id in the session data, as well =20
as a number of other account-specific items. Once I was made aware of =20=
the multiple-window requirement, and started looking more closely at =20
sessions, it seemed (from the PHP documentation) that I could start a =20=
new session, with a different name and id, and that would take care =20
of it. In fact I CAN start sessions with independent names and ids, =20
but their DATA doesn't seem to be completely independent.
Charles Whitaker
Technical Staff
Open Door Networks
--Apple-Mail-1--259115855--
RE: independent session data for multiple browser windows
am 20.02.2008 20:18:56 von Gary Wardell
>
> They'll be accessing different account records in different windows.
> I keep track of the current account id in the session data, as well
> as a number of other account-specific items. Once I was made
> aware of
> the multiple-window requirement, and started looking more closely at
> sessions, it seemed (from the PHP documentation) that I could
> start a
> new session, with a different name and id, and that would take care
> of it. In fact I CAN start sessions with independent names and ids,
> but their DATA doesn't seem to be completely independent.
>
Assuming that they are interacting through forms on the pages in the different windows, why not put the UID of the record they are
accessing in a hidden field in the form?
Gary
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: independent session data for multiple browser windows
am 27.02.2008 23:01:45 von chas
--Apple-Mail-39-356722627
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed
On Feb 20, 2008, at 11:18 AM, Gary Wardell wrote:
>>
>> They'll be accessing different account records in different windows.
>> I keep track of the current account id in the session data, as well
>> as a number of other account-specific items. Once I was made
>> aware of
>> the multiple-window requirement, and started looking more closely at
>> sessions, it seemed (from the PHP documentation) that I could
>> start a
>> new session, with a different name and id, and that would take care
>> of it. In fact I CAN start sessions with independent names and ids,
>> but their DATA doesn't seem to be completely independent.
>>
>
> Assuming that they are interacting through forms on the pages in
> the different windows, why not put the UID of the record they are
> accessing in a hidden field in the form?
Gary,
Thanks for your reply. I'm beginning to think that that's what I'll
have to do, although it will be a bit of work to convert. I'm
surprised, though, that sessions aren't better in regards to data
integrity. What I'm gathering from looking into this is that it's ok
to use sessions, but you shouldn't count on reliable data from them.
I don't remember seeing any caveats to that effect in the
documentation on sessions, but that seems to be the case.
Anyone know differently? Thanks.
Charles Whitaker
Technical Staff
Open Door Networks
--Apple-Mail-39-356722627--