Re: [phplib] Session variables shared among browsers question From: Maurice Jumelet (maurice <email protected>)
Date: 10/17/00

What you need is an new session_id if the user opens a new browser, however,
the session id is either stored in the URL (which is copied if the user
opens a new window) or in the cookie (which reads the same session id if you
open an new window), in you case we manually need to redirect the user to a
new session if he opens a new window, only how do you detect an user opens a
new window and didn't just reload his window?

There is no way for you to detect if the user opens a new window (CTRL+N)
or whether he "reloaded" the window either by some autoreload or by pressing
F5.

It might be possible if you use some counter in the URL and you match it
against some internal session variable, I provided some sample code I hope
that works. I have not in anyway tested my code and I almost sure made some
typos. One problem with this code is that the original windows get
redirected to a new session_id (at the automatic reload) and the new window
stays at the old session.

I think you must disable cookies in this code, use "get" mode.

so in local.inc:
$sess->mode = "get";

open your test page with:

http://test.com/view.php?counter=1

<?php
page_open(bla,bla)

if (!$sess->is_registered("internal_counter")) {
    $internal_counter = 0;
    $sess->register("internal_counter");
}

if ($internal_counter == $counter) {
    /* normal reload, redirect user to new valid counter value */
    header("Location: http://test.com/view.php?counter=" . $counter + 1 );
    page_close(); /* store session data */
    die("redirected");
}

if ($internal_counter > $counter ) {
    /* double load, redirect user to new session */
    header("Location: http://test.com/view.php?counter=1&sess_id=" .
md5(uniqid("SECRET_HASH")) );
    page_close(); /* store session data */
    die("redirected to new session");
}

/* update internal counter */
$internal_counter++;

/*
    do your stuff here

*/

page_close(); /* make sure you do this */

?>

I hope this works or in anyway helps you,

Maurice Jumelet
http://www.noxx.com

----- Original Message -----
From: "Johan Edback" <jed <email protected>>
To: <phplib <email protected>>
Sent: Tuesday, October 17, 2000 8:14 PM
Subject: [phplib] Session variables shared among browsers question

> Hi all!
>
> I'm using phplib 7.2b with apache 1.3.12 and mysql 3.22.32, and I'm
> writing an application that will allow the users to monitor some queues
> (the information is stored in plain text files).
>
> The problem is that when a user has two browsers open and tries to look at
> two different queues at the same time, it works for one minute until the
> browser auto-reloads the page and then both brosers are show the
> information about the same queue, not two different queues.
>
> I'm using $sess->register("project"); to create the variable in which I
> store which project-queue to monitor.
>
> So, my question is: is there a way in phplib to save a session variable
> that is unique to the browser (so that if the user opens new browser
> File->New->Navigator window for instance), then the user would be given a
> new session variable, and thus being able to monitor two queues?
>
> Many thanks to the developers, you are doing a great job!!
>
> //Jed
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: phplib-unsubscribe <email protected>
> For additional commands, e-mail: phplib-help <email protected>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>