How does web applications handle multiple browser window - session

I have a very basic knowledge of the web programming, and I couldn't figure out the answer to this question.
Typically, a cookie is used to identify a session in web applications. However, as far as I know, multiple browser windows share cookies. In that case, how does web applications distinguish between the tabs?
Edit: I guess all the answers are saying the same thing - there is no standard way to handle this. Ok. Thanks for resolving my uncertainty guys.

However, as far as I know, multiple browser windows share cookies. In that case, how does web applications distinguish between the tabs?
It cannot distinguish at all. Hence comes the challenge for web developers - make their application robust to prevent data destruction or unauthorized operations when access is performed from some other "outdated" tab.

They don't. The application does not know that you have two tabs open. If you are tracking sessions then it can know that you have two sessions open.
What are you trying to accomplish?

They don't. You have one cookie per different browser (ff/ie/ google chrome).
You'll have to distinguish the tabs client-side (ie Javascript).

Related

Can I use a websocket connection within a serviceworker to receive notifications while my PWA is closed?

I was wondering whether it is possible to host a websocket connection within the boundaries of a serviceworker.js in order to receive notifications while my PWA is closed.
Given the documentation, the regular Push API is the proposed and go-to solution here, but I'm interested whether this is also possible via WebSockets, because my application would be way nicer to work with due to existing libraries for the programming language I use.
Also, websockets would give me an easy way of knowing whether or when my users are online / offline.
So, is this possible in a serviceworker.js, or would it lose the connection under certain circumstances?
Short answer, no.
The service worker is a somehow a thread of a web page. A web page (usually) lives in a tab of a browser (a PWA is also managed by a browser engine). Nowadays browsers are gearing towards performance and a lower memory footprint (think mobile). So the browser will kill (or sleep) your page as soon as it thinks it can because you're not using a page you're not viewing. Yes, a WebSocket will give you some priority against normal pages, but not that much.
Then there is the OS running the browser. Its main mission is to manage resources, like CPU cycles and RAM memory. And yes, it'll also try to kill you sooner than later.

Emulating multiple clients to a web server

If possible i want to use my computer to emulate multiple clients (like TPC-W) on a web server, i tried to use Htmlunit however when i created two WebClient() they had the same login session (when one logged in the other was logged in as well in a stateful bean, it causes the second one to crash because the login form disappears after the logging in).
The reason i'm not using TPC is because i want to benchmark on my own web pages. I'd like to know if it is possible to use TPC to emulate my own pages or a library/trick that can do the job.
It seems the answer to my question was written in the following question.
prevent Shared session with multiple browser windows
The answer is: multiple logins in a single session. Thanks goes to user191966 for the answer.

Changing domain linked to a Selenium::Client::Driver instance

I'm using the Selenium Client (v 1.2.18) to do automated navigation of retail websites for which there exists no external API. My goal is to determine real-time, site-specific product availability using the "Check Availability" button that exists on a lot of these sites.
In case there's any concern, each of these checks will be initiated by a real live consumer who is actually interested in whether or not something's available at that store. There will be no superfluous requests or other internet badness.
I'm using Selenium's Grid framework so that I can run stuff in parallel and I'm keeping each of the controlled browsers open between requests. The issue I'm experiencing is that I need to perform these checks across a number of different domains, and I won't know in advance which one I will have to check next. I didn't think this would be too big an issue, but it turns out that when a Selenium browser instance gets made, it gets linked to a specific domain and I haven't been able to find any way to change what domain that is. This requires restarting a browser each time a request comes in for a domain we're not already linked to.
Oh, and the reason we're using Selenium instead something more light-weight (eg. Mechanize) is because we need something that can handle JavaScript.
Any help on this would be greatly appreciated. Thanks in advance.
I suppose you are restricted from changing domain because of same origin policy. Did you try using browser with elevated security privileges like iehta for internet explorer and chrome for firefox browsers. While using these modes of browsers, use open method in your tests and pass the URL which you want to open. This might solve your problem.

Implementing Real-Time Collaboration On A Page?

I would like to create a web page which would allow multiple users to work together on a page, Imagine a web based editor that allowed to users to change the documents as an example of this type of feature.
How would more experienced programmers go about implementing this as i really cant seem to formulate any way to even begin going about this task. Would there be any programming librarys that make implementing this feature easier or is it just too complex to even think about?
I am creating this webapp primarily using GWT and SmartGWT if that helps.
Thanks for any input you may have.
There is indeed a cometd-like library for gwt - http://code.google.com/p/gwteventservice/
Wiki:
In web development, Comet is a neologism to describe a web application model in which a long-held HTTP request allows a web server to push data to a browser, without the browser explicitly requesting it. Comet is an umbrella term for multiple techniques for achieving this interaction. All these methods rely on features included by default in browsers, such as JavaScript, rather than on non-default plugins.
In practice:
In normal way client can receive resources by request->responce. It is no possible to send data directly to client without request. With comet you can hold realtime connection between client and server and exchange data in realtime.
Check out: docs.google.com. They are using comet.
Etherpad.com is a service that used to do this. It has been since bought by Google, and the code released as open-source. You can see several links on the etherpad.com page for the source download and related information.

Is there a super-high-load (Ajax) chat script out there?

For a pet project, I have been looking for a web chat script capable of running potentially tens of thousands of users simultaneously. I don't want to use any kind of applet or browser extension, so on the client side, it should be simple Ajax. On the server side I'm pretty much open to anything.
I'm not looking for bells and whistles, a simple text-only chat is more than enough, as long as it supports a number of 'channels' or 'rooms' simultaneously, and a very large number of users.
When I first started researching the chat scripts out there, it seemed like the only viable option was to run an IRC server and just build a web interface on top of that. I know I could get good performance and stability with that setup, but could I get better performance by using something else?
Any ideas?
You might want to check cometd
I believe there are some chat scripts already using cometd.
I have no idea regarding stability tho.
You can have a look at Jabbify.
Not sure about the rooms and channels part, but it is built on the AJAX and MVC model.
I am going with Twitch.me, which is based on node.js

Resources