Please note, this question is not about client-server sessions. It's about Chrome session.
I'm reading this article about tabId
and it states that:
Tab IDs are unique within a browser session.
What is browser session here? Does the session begin when I open a browser and ends when I close it? Is there a way to track tab across sessions?
The Session object represents a tab or window that the user has closed in the current browsing session. Sessions are represented as Tab objects if the tab was closed but its window was not closed: for example, because the user clicked the "Close tab" button, and this tab was not the only tab in its window.
Overview. A session is a group of user interactions with your website that take place within a given time frame. For example a single session can contain multiple page views, events, social interactions, and ecommerce transactions.
The session extension provide a mechanism for recording changes to some or all of the rowid tables in an SQLite database, and packaging those changes into a "changeset" or "patchset" file that can later be used to apply the same set of changes to another database with the same schema and compatible starting data.
Click the Application tab to open the Application panel. Expand the Session Storage menu. Click a domain to view its key-value pairs. Click a row of the table to view the value in the viewer below the table.
What is browser session here? Does the session begin when I open a browser and ends when I close it?
That's correct. It means a tab will preserve its ID only until you close the browser.
Even if the browser is configured to reopen the previews windows on startup, they will all have a different tab ID and window ID.
Is there a way to track tab across sessions?
Yes, with the tabs
permission! Mostly.
The IDs will be different but you can query all the open tabs and windows and you will receive the position of a tab in a window (e.g. first tab in window 2) together with its URL. You'd have to regularly query and save this data via chrome.storage.local.set()
You can then compare this piece of information to the data you stored before closing the browser and match them to each other. For example you receive tab on position 1, with URL xyz, in a window with 3 other tabs
, you can find a tab with the same details in your storage.
The "mostly" part: If the user has 2 windows with 1 tab, both pointing to the same page, you won't be able to tell which is which.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With