473,729 Members | 2,353 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tabbed browsing and sessions

Am I right in assuming that when I connect from one browser, using several
tabs to a database produced in mysql/php/apache only uses one session for
all tabs? I have been loosing records from my database and my best guess
is that each tab is not a separate session, therefore the session variables
are shared by all tabs and unfortunately this plays havoc when I try to
update my database using the forms I have created.

Is there anyway to force each tab to have a separate session, if that is my
problem? My application was written not realising this potential problem
and I am a bit stumped on how to fix it. At least I am the only user so I
know not to break it.

:-(

Pete
--
http://www.petezilla.co.uk
Jul 17 '05 #1
17 8025
Peter Chant <pe**@petezilla .co.uk> wrote:
Is there anyway to force each tab to have a separate session,
No. Tabs are nothing special in anyway to the server.
if that is my problem?
No, the problem is that your application isn't "thread safe".
My application was written not realising this potential problem and I
am a bit stumped on how to fix it.


Don't use the session to store variables in a "global scope". You
mentioned forms, so you could generate random IDs per form and use that
to store the sessionvars for that form:
$_SESSION['formid_foo']['foo']='foo';
$_SESSION['formid_bar']['foo']='bar';

Jul 17 '05 #2
*** Peter Chant wrote/escribió (Thu, 21 Apr 2005 01:14:18 +0100):
Am I right in assuming that when I connect from one browser, using several
tabs to a database produced in mysql/php/apache only uses one session for
all tabs?
As you know, browsers do not use sessions, they merely send session IDs to
server, typically using cookies. The browser will send the cookie if
instructed to do so. If the cookie is set to be deleted when browsing
session ends, I believe you need to (al least) close all open browser
windows. So I'd say tabs are not the problem.
I have been loosing records from my database and my best guess
is that each tab is not a separate session, therefore the session variables
are shared by all tabs and unfortunately this plays havoc when I try to
update my database using the forms I have created.


Session variables are for values that must be shared among pages. Yours
seems to be the opposite case: values must *not* be shared. Why use
sessions then? Anyway, if they're strictly necessary I guess you can create
a session with a random name and store that name in the form itself.
Something like:

if($_POST['session_name']!=''){
session_name($_ POST['session_name']);
session_start() ;
}else{
// Create new session or display error, whatever
}

My code probably won't work, but I hope it gives you an idea.
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Jul 17 '05 #3
I have currently the same problem, if I got you right that is. I
designed a athentication/session system and now I find out that when I
open different instances of the same browser (hitting New Tab in
Firefox or File - New - Window in IE, as opposite of double-clicking
the desktop IE icon again) the navigation window duplicates, and both
windows now are in the same page, use the same session and therefore
the same session vars, hence messing everything up when navigating
simultaneously.

Still looking for a solution :|

Jul 17 '05 #4
Alvaro G Vicario wrote:


As you know, browsers do not use sessions, they merely send session IDs to
server, typically using cookies. The browser will send the cookie if
instructed to do so. If the cookie is set to be deleted when browsing
session ends, I believe you need to (al least) close all open browser
windows. So I'd say tabs are not the problem.
Well, I have left various browsers open on various desktops. I first became
aware when using a tabbed browser. I think the problem is if I have two
copies of my 'edit member' form open, one for Tom and the other for Dick.
If they both exist in the same session and I use one variable to store the
persons ID, $cont_id I have good chance of overwriting Tom's data with
Dick's and vice versa.

Session variables are for values that must be shared among pages. Yours
seems to be the opposite case: values must *not* be shared. Why use
sessions then?
Well, I thought that sessions were 'A Good Thing (TM)'?

I should have just stck to post data.

Anyway, if they're strictly necessary I guess you can
create a session with a random name and store that name in the form
itself. Something like:

if($_POST['session_name']!=''){
session_name($_ POST['session_name']);
session_start() ;
}else{
// Create new session or display error, whatever
}

My code probably won't work, but I hope it gives you an idea.


Hmm, kind of see where you are coming from, not quite sure putting the
session name is quite the right plan.

It looks like when I submit a form I need to include in the form, not the
session variables, the id of the database record that the particular form
relates to.


--
http://www.petezilla.co.uk
Jul 17 '05 #5
Samuel Caparrós wrote:
I have currently the same problem, if I got you right that is. I
designed a athentication/session system and now I find out that when I
open different instances of the same browser (hitting New Tab in
Firefox or File - New - Window in IE, as opposite of double-clicking
the desktop IE icon again) the navigation window duplicates, and both
windows now are in the same page, use the same session and therefore
the same session vars, hence messing everything up when navigating
simultaneously.

Still looking for a solution :|


Hmm,

if I'd known perhaps it would have been easier to not use sessions, or
limited them to storing which style sheet I wanted to uses for the pages.
Though I can see some advantage in using the same session with multiple
pages if each were separate we would both not be in this mess.
--
http://www.petezilla.co.uk
Jul 17 '05 #6
Daniel Tryba wrote:
Peter Chant <pe**@petezilla .co.uk> wrote:
Is there anyway to force each tab to have a separate session,
No. Tabs are nothing special in anyway to the server.
if that is my problem?


No, the problem is that your application isn't "thread safe".


! I did not know what that meant until know, learning the hard way.

My application was written not realising this potential problem and I
am a bit stumped on how to fix it.


Don't use the session to store variables in a "global scope". You
mentioned forms, so you could generate random IDs per form and use that
to store the sessionvars for that form:
$_SESSION['formid_foo']['foo']='foo';
$_SESSION['formid_bar']['foo']='bar';


Eek. You seem to suggest re-inventing sessions again to create
'sub-sessions' for each form!

I assume I would have to pass the random id as post (get?!) data or a hidden
form field (I can't remember the name of the appropriate tag). It might be
just as easy to pass the variable in question, $cont_id since only I use
this app so people fiddling with the variable is not a problem.

It looks like this multiple tabs thing really takes away a lot of the
advantages of sessions in PHP.

--
http://www.petezilla.co.uk
Jul 17 '05 #7
"Samuel Caparrós" <le*********@gm ail.com> wrote in
news:11******** **************@ z14g2000cwz.goo glegroups.com:

Still looking for a solution :|

use different web-browsers at the same time. that way you can double-check
your css too.

Jul 17 '05 #8

"Samuel Caparrós" <le*********@gm ail.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
I have currently the same problem, if I got you right that is. I
designed a athentication/session system and now I find out that when I
open different instances of the same browser (hitting New Tab in
Firefox or File - New - Window in IE, as opposite of double-clicking
the desktop IE icon again) the navigation window duplicates, and both
windows now are in the same page, use the same session and therefore
the same session vars, hence messing everything up when navigating
simultaneously.

Still looking for a solution :|


I came across this very same problem some while ago, and it took quite some
time to figure out a solution. The biggest problem is that "new tab" or
"new" does not actually open up a new browser instance, it merely creates a
clone of the current instance. This clone includes browser history as well
as the session name, and it is the session name which provides the session
id which is used to link with session data on the server. My solution is as
follows:

1) Completely new instances, not clones, can only be created by avoiding the
"new tab" and "new" options. The user must start a completely new browser
instance from scratch.
2) The application must use a session name which is different to the default
PHPSESSID. In my application I use "menuNN" where "NN" is an
auto-incrementing number. As the relationship between session names and
session id's is one-to-one, the only way to have multiple sessions id's in
use at the same time is to have multiple session names.
3) The user must start the application at the logon screen, as it is only
the logon process which can choose a new session name. The session id is
allocated automatically. In my logon process I scan to see which session
names are currently in use, then allocate a new one by incrementing the "NN"
value. The session name thus generated must therefore be included in all
URLs, otherwise the link to a specific set of session data will be lost.

Tricky, but it works.

--
Tony Marston

http://www.tonymarston.net

Jul 17 '05 #9

Tony Marston wrote:
1) Completely new instances, not clones, can only be created by avoiding the "new tab" and "new" options. The user must start a completely new browser instance from scratch.


Of course :) That solves the problem, but still I have to either

1) convince the customer to not use "clones" under any circumstances to
navigate simultaneously, but creating new browser windows for that (my
current system works fine with this).
2) make sure the customer will get an error if creating a "clone" (this
would be ideal, but that's where I'm lost).

I've been thinking of creating a txt dummy file on server, named after
the SID, that each page would open and keep open. Then a Javascript
would close it before page transition. The next page would check wether
the file is in use or not, and return an error if so.

I'll try today and see what I can get. But I can already foresee the
first problem; popup windows or Right Click - Open in new window would
give problems. And these are more common than your average "New Tab"
user, as far as I can see.

Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3173
by: Ashutosh | last post by:
Hello, I want to create a mdi application in vb.net. The user should be able switch among different child windows like tabbed browsing feature in firefox. Can someone point me to the source code or any similar examples. Regards, Ashutosh
1
1528
by: Jim Hubbard | last post by:
I'd love to see a VB.Net 2.0 example of a tabbed interface. It could be a notepad-type or browser-type application....doesn't matter. What would be great is an example that incorporated a custom control or interface on each tab and not just a simple single control per tab. Thanks for your help.
4
7423
by: Martin | last post by:
Hi all! As a preparation of a conversion from VB6 to VB2005 I'm playing around with VB2005. One of the first things that strike me is the user-interface. In all documentation Microsoft keeps going on about this beautiful Tabbed MDI Interface that we all should be using. And I agree, it is nice. So I set out to build my first test-app and guess what? I can't find how to create a Tabbed MDI Interface... I do see the "old" MDI container,...
3
2770
by: kev | last post by:
Hello, I posted a question a while ago on tabbed pages, how to set it to invisible when the text box is empty.It was answered by Rick and the code ran perfectly. However, i tried using the same code for another scenario and it gives me compile error:method or data member not found. My scenario is i have a nested tab page.My main tabbed page has 4 tabs, About, SafetyLevel1,SafetyLevel2,SafetyLevel3. Inside this main, i created a...
0
7511
NeoPa
by: NeoPa | last post by:
Originally posted by Missinglinq: The first thing to remember is that Tabbed Pages are all part of a single form; think of it as a really long form turned on its side and folded on itself. Because it is all one form, references to contols on any page are done in the same manner as if they were all on one single screen. Create a form in Design View. Goto the toolbox and click on the Tabbed Control icon; it actually looks like several...
4
2668
by: GaryDean | last post by:
Bringing up a new browser instance when using an asp.net application using forms authentication, of course, initiates a new session with a new sessionID and requires authentication again. But, I see that browsing to that same asp.net application using a new tab in ie7 or firefox uses the same SessionID and does not require separate authentication. This means that the same session can be on two different pages at the same time. Is...
11
2620
by: AndyM | last post by:
Hi, I have a curious problem that is causing me large amounts of grief and is steadily turning me grey. Hopefully you guys can help. I have a Master table that contains a CustomerID (as well as customer name etc), this is used as the Primary key to all the tables relating to that customer. I've been using 1 to Many relationships for most of the tables (e.g A customer can have many addresses) with Referential Integrity and cascading turned...
0
907
by: =?Utf-8?B?Um9ib2NvcA==?= | last post by:
I am having problems with the tabbed browsing as well. I went into Internet options>Generaland clicked settings under tabs>and clicked open home page in new tab, instead of blank page. But, it still will not open my home page in the new tab! It's just a blank page. Any suggestions? I am running Windows XP Home Ed. with S.P. 3, and IE7.
19
7263
by: hedges98 | last post by:
Sorry for the mouthful of a title! Basically, I have a form with tabbed controls (Personal/Contact Details, Referral Information, Case Info/Status etc.) and I want to add a tabbed control form inside one of the existing tabs. At the moment there are two tabs called Appointments and Group Appointments. What I want to do is add a tabbed control inside the Appointments tab with two tabs called Individual Appointments and Group Appointments...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8148
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2163
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.