unique id of window tab in web browser

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
raysleith
Forum Newbie
Posts: 10
Joined: Sat Oct 04, 2008 10:26 am

unique id of window tab in web browser

Post by raysleith »

i wanna ask if there is a unique id for each window tab in web browser? how to obtain it in php?
my problem is, i wanna redirect people that tracked by $_SESSION. But this will only works if he use one window tab to browse the page.

thanks
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: unique id of window tab in web browser

Post by requinix »

You can't do that. Find another way.
raysleith
Forum Newbie
Posts: 10
Joined: Sat Oct 04, 2008 10:26 am

Re: unique id of window tab in web browser

Post by raysleith »

hm...
any suggestions about technique to redirect url?
or any one know how this devnetwork forum redirect when you have submit a reply then return to the topic?

thanks
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: unique id of window tab in web browser

Post by requinix »

The typical way of redirecting people is to execute

Code: Select all

header("Location: /url");
exit;
before you've printed anything.

If you explain a little more about what you want to do maybe we'll understand why "this will only works if he use one window tab to browse the page".
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: unique id of window tab in web browser

Post by alex.barylski »

From what I have determined in javascript...tabs do not behave the same as windows at least IE.

I was experiementing with a web desktop I was developing and one of the things I wanted to do was use the desktop system tray icons essentially re-display the tab which represent that application.

While storing the window ID in IE worked as soon as I switched to tab mode the window.setfocus() or whatever function called to bring a window to the front stopped working. I believe I tried this in FF, OP and Safari as well with no success. Kind of bummed me out cause the idea was really neat. :)

Although technically it makes some sense as a tab, is not nessecarily a "window" in that sense of the word.
raysleith
Forum Newbie
Posts: 10
Joined: Sat Oct 04, 2008 10:26 am

Re: unique id of window tab in web browser

Post by raysleith »

this is what i'm trying to do
example i would reply a post on topic A, let say with tab 1.
On tab 1, after i reply a topic, it will be redirect to the topic A url.
I do this using session value. This value is saved when i visit topic A.

But in the same time if i want to reply topic A, if theres also opened tab 2 that i would like to reply a post on topic B, the session will be overwritten isnt it?
so the redirection will be failed.

Thanks
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: unique id of window tab in web browser

Post by alex.barylski »

SESSION's are as good as their client side persistence mechanism used...

If SESSION ID's are stored in cookies then tabs will work fine I do this all the time on these boards with no issues...open a topic in a new window and reply that is.

If SID is propagated via GET then opening a new window would require you to pass along the SID with the window.open request.
raysleith
Forum Newbie
Posts: 10
Joined: Sat Oct 04, 2008 10:26 am

Re: unique id of window tab in web browser

Post by raysleith »

PCSpectra wrote:SESSION's are as good as their client side persistence mechanism used...

If SESSION ID's are stored in cookies then tabs will work fine I do this all the time on these boards with no issues...open a topic in a new window and reply that is.

If SID is propagated via GET then opening a new window would require you to pass along the SID with the window.open request.
i dont understand >.<
is the session id of each tab is different?

here's my example on using the redirection:

topic_detail.php

Code: Select all

 
<?php
session_start();
$_SESSION['lastURL'] = getThisURL();
?>
<a href='write_reply.php?id=1'>Write reply</a>
 
write_reply.php

Code: Select all

 
<?php
session_start();
//do processing...
header("Location: redirect.php");
?>
 
redirect.php

Code: Select all

 
<?php
session_start();
if( isset($_SESSION['lastURL']) ){
header("Location:" .  $_SESSION['lastURL']);
} 
?>
 
GC Ben
Forum Newbie
Posts: 1
Joined: Thu Oct 16, 2008 2:31 am

Re: unique id of window tab in web browser

Post by GC Ben »

Just read about interesting related technology. I'm sure if you google http Sub-Sessions for different tabs you will find some answers. Url rewriting allows multiple sessions.
raysleith
Forum Newbie
Posts: 10
Joined: Sat Oct 04, 2008 10:26 am

Re: unique id of window tab in web browser

Post by raysleith »

i thought about window.name property to handle this problem.
i think, i could assign each tab with unique window.name, that may be generated by timestamp or something.
so i could add session value with prefix + window.name
any suggestions?
Post Reply