Session value in multiple tabs

Schema:
id auto-increment,
date date

List Page, date as extended-search.
Page_Render()
$_SESSION[“something”] = $this->date->AdvancedSearch->SearchValue;

Add Page, auto-update date.
Row_Inserting()
$rsnew[“date”] = $_SESSION[“something”];

Problem:
If user open 2 (or more) browser-tabs with different extended-search value then $_SESSION[“something”] will fire wrong value into $rsnew[“date”].

Any ideas to solve this problem?

Thanks.

Note that the PHP session in multiple tabs is the same one, but you may read: https://discourse.hkvstore.com/t/ensuring-data-integrity-with-master-detail-tables/1177/1

Thanks for the pointer but for my specific case I think I’ll better use client session-storage and add some logic into Row_Inserting.

I’ve been SO-ing this problem for hours, turns out this is server vs. client kind of problem. Working server-side for client-side problem could cause more problems than it solved. There’s no way for server to know “tab-identity” of client.
The appropriate approach, surely then, is to work client side.
Local/Session storage does not secure by nature. Cookie does. So I think this problem should be solved by cookie.

Hi, Sangandar

The solution I provided is designed to resolve your exact issue: multiple tabs open in the same browser

With this solution, the server DOES know the identity of every relevant tab or window, and ensures that the correct $_SESSION variables are used in relation to its activities (which includes search fields as well as master / detail data).

I believe your solution does work.
I haven’t yet code my “session-storage” approach. I think it would be simpler.
I’ll post here as the code is done.

Always interested to see alternate solutions :slight_smile:

Please post it in the User Tips section once you have it working.

See viewtopic.php?f=18&t=49211 for my alternate solution.