This topic might give you some insight into the Firefox cookie handling: Firefox session cookies
Also, it is not clearly stated in the question what do you want to achieve. If you are interested in fixing the issue just for yourself, then consider changing the Firefox mode. If you want to fix it for any Firefox-based website user, then consider mentioning the technology you use for creating the website.
UPD:
One the one hand,
Not specifying Expires value on the cookie will cause the cookie to be removed when the browser session ends i.e. when user closes the browser.
On the other hand, as it was stated in the post above, Firefox handles cookies in a slightly different way.
For that reason, you could use the short cookies Expires value and update it periodically while user is online.
You may also use unload
and onbeforeunload
events, which could help you to detect leaving the website by closing tab or going to another address.
The following model is also possible:
On the client side:
once a user opens a new tab,
some ID is given to this in js code,
and that ID is sent to the server as an ID to create;
once a tab is closed,
its ID is sent to server by js code as an ID to remove;
On the server side:
once a server receives an ID to create,
it generates a session ID and returns it to a client;
once a server receives an ID to remove,
it checks, if there are any more tab IDs left,
if there are some, it just removes a tab ID from an array of those IDs;
if there are no more, it removes the session and clears its tab IDs array;