Consider I've this page: sample.php
<div id="id1" style="display: none">
Hello
</div>
Initially when the page loads, this div is not displayed, but I've a button1. When I click on this button, it changes the display value to block.
There's another button2 that I use to change the display value back to none.
So, this div is visible only when the button1 is clicked. In other cases (when the page is reloaded or when button2 is clicked), it would be invisible.
Now, suppose that I've opened this same page in 4 more tabs (it can be even more, I'm giving just example) of a browser. And I've pressed button1 in any 2 of them. That means this div is visible in those 2 tabs.
Now, what I want is that when the div is visible, the text inside it should store in a SESSION variable. And I can do it using JavaScript, jQuery, Ajax and PHP. When the two tabs have 2 visible divs, their text "Hello" is stored in a same SESSION variable (it will store only "Hello" only, not "HelloHello" since SESSION will get replaced by new request as my Ajax and PHP code will run on all tabs at the same time).
Now what I finally need is that when those 2 visible divs in 2 differents tabs are set to display: none, it should unset the SESSION variable that has "Hello" in it.
Because my condition for unsetting it is that none of the 4 tabs should have that div visible. If any of the tab has div visible, the SESSION would have "Hello" in it.
PS: I've tried to explain a lot my problem, but still if you don't understand, please mention it in comment, before answering:
Thank you.