By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,677 Members | 1,224 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,677 IT Pros & Developers. It's quick & easy.

session & browsers (final)

P: n/a
I ask something relative later but the answer make me cry ;-)
If we duplicate the browser window (both in IE / Mozilla), both of 2 browser windows use the same session!!!
This produces many problems...

My program is this:
I have html format books inside zip files.
If I choose a book from my main page, php sets
$_SESSION['book'] = "a_book.zip";
and loads the index.html from a_book.zip.
if we click a link inside index.html like:
<a href=chapter1.html>Next</a>
Apache returns error 404, php handles this error and returns file chapter1.html from a_book.zip

All right but the problem is this:
If I duplicate browser window and in the 2nd browser I select another book, then because both of 2 browser use the same session, 2nd
browser change the $_SESSION['book'] and 1st browser searches in wrong zip file.

Any suggestions?

Regards
Gessos Paul

Jul 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a

"<- Chameleon ->" <ch******@hotmail.NOSPAM.com> a écrit dans le message de
news: bn**********@nic.grnet.gr...
I ask something relative later but the answer make me cry ;-)
If we duplicate the browser window (both in IE / Mozilla), both of 2 browser windows use the same session!!! This produces many problems...

My program is this:
I have html format books inside zip files.
If I choose a book from my main page, php sets
$_SESSION['book'] = "a_book.zip";
and loads the index.html from a_book.zip.
if we click a link inside index.html like:
<a href=chapter1.html>Next</a>
Apache returns error 404, php handles this error and returns file chapter1.html from a_book.zip
All right but the problem is this:
If I duplicate browser window and in the 2nd browser I select another book, then because both of 2 browser use the same session, 2nd browser change the $_SESSION['book'] and 1st browser searches in wrong zip file.
Any suggestions?

Regards
Gessos Paul


sorry for makin' you cry :)

for your problem, maybe you should try to use a random ID (or book name if
unique) for each search made on your Zip or something like that.
You should add something in your session to identify which book you're
using.
something like :
$book["RANDOM_ID"]["BOOK"]
$book["RANDOM_ID"]["OTHER_VAR_RELATED_TO_THIS_BOOK"]

You'll need to write a script to manage those vars and crush the session
var.

hope it'll help
Regards,
Julien.

Jul 17 '05 #2

P: n/a
> > I have html format books inside zip files.
If I choose a book from my main page, php sets
$_SESSION['book'] = "a_book.zip";
and loads the index.html from a_book.zip.
if we click a link inside index.html like:
<a href=chapter1.html>Next</a>
Apache returns error 404, php handles this error and returns file chapter1.html from a_book.zip

All right but the problem is this:
If I duplicate browser window and in the 2nd browser I select another

book, then because both of 2 browser use the same session, 2nd
browser change the $_SESSION['book'] and 1st browser searches in wrong zip file.

for your problem, maybe you should try to use a random ID (or book name if
unique) for each search made on your Zip or something like that.
You should add something in your session to identify which book you're
using.
something like :
$book["RANDOM_ID"]["BOOK"]
$book["RANDOM_ID"]["OTHER_VAR_RELATED_TO_THIS_BOOK"]

You'll need to write a script to manage those vars and crush the session
var.


Thank you for your response, but I don't understand. Sorry ;-(
first of all book name is unique. I have 2 browser windows:
1st has $_SESSION['book'] = 'php_manual.zip'
2nd overide $_SESSION['book'] = 'thinking_in_cplusplus.zip' because has the same session
so when 1st gets image: image.jpg from an <A> tag, php search inside 'thinking_in_cplusplus.zip' and not inside 'php_manual.zip'

You suggest $_SESSION['book'] will be an array? How it help?
thank you
Jul 17 '05 #3

P: n/a
On Thu, 30 Oct 2003 17:38:18 +0200, <- Chameleon -> wrote:
Thank you for your response, but I don't understand. Sorry ;-(
first of all book name is unique. I have 2 browser windows:
1st has $_SESSION['book'] = 'php_manual.zip'
2nd overide $_SESSION['book'] = 'thinking_in_cplusplus.zip' because has the same session
so when 1st gets image: image.jpg from an <A> tag, php search inside 'thinking_in_cplusplus.zip' and not inside 'php_manual.zip'

You suggest $_SESSION['book'] will be an array? How it help?
thank you


He's saying that you need to use a unique identifier for each book OTHER
than the generic name 'book'. (Also note that the session for a browser
and ALL of its open windows is the same session.)

So if book names are unique, track the book by using the name of the book,
instead of the very generic variable name "$book".

Something like

$_SESSION['book_list']['a_book'] = 'a_book_file.zip';
$_SESSION['book_list']['b_book'] = 'b_book_file.zip';
$_SESSION['book_list']['c_book'] = 'c_book_file.zip';

etc...

That makes an array $_SESSION['book_list']. Use that array to keep all
the books in one place, but use a different key for each book, in this
case the key is the book's name.

Hope this helps. If not, then learn more about Arrays, Multi-dimensional
arrays, Associative arrays, and Sessions. Go to
http://www.php.net/manual/ for that.

later...
--
Jeffrey D. Silverman | jeffrey AT jhu DOT edu
Johns Hopkins University | Baltimore, MD
Website | http://www.wse.jhu.edu/newtnotes/

Jul 17 '05 #4

P: n/a
> He's saying that you need to use a unique identifier for each book OTHER
than the generic name 'book'. (Also note that the session for a browser
and ALL of its open windows is the same session.)

So if book names are unique, track the book by using the name of the book,
instead of the very generic variable name "$book".

Something like

$_SESSION['book_list']['a_book'] = 'a_book_file.zip';
$_SESSION['book_list']['b_book'] = 'b_book_file.zip';
$_SESSION['book_list']['c_book'] = 'c_book_file.zip';

etc...

That makes an array $_SESSION['book_list']. Use that array to keep all
the books in one place, but use a different key for each book, in this
case the key is the book's name.

Hope this helps.


Thank you but it is wrong ;-)
Wrong because you want a key (the book's name).
Where can I store this key? In Session? In this case we fall in the start of the problem.
I cannot use GET, POST & COOKIE
Jul 17 '05 #5

P: n/a
On Thu, 30 Oct 2003 21:44:33 +0200, <- Chameleon -> wrote:
Thank you but it is wrong ;-)
Wrong because you want a key (the book's name).
Where can I store this key? In Session? In this case we fall in the start of the problem.
I cannot use GET, POST & COOKIE


You lost me there. Why can't you store the book's name in a session?
--
Jeffrey D. Silverman | jeffrey AT jhu DOT edu
Johns Hopkins University | Baltimore, MD
Website | http://www.wse.jhu.edu/newtnotes/

Jul 17 '05 #6

P: n/a
> > Thank you but it is wrong ;-)
Wrong because you want a key (the book's name).
Where can I store this key? In Session? In this case we fall in the start of the problem.
I cannot use GET, POST & COOKIE


You lost me there. Why can't you store the book's name in a session?


because 2nd browser windows which points in other book will overide 1st browser book's name.

anyway, I found other method to accomplish:
Until now I dont knew that:
I can pass data with GET with this:
book.php/thinking_in_cplusplus.zip/index.html

All are easy now

thanks
Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.