Logout all open tabs automatically when user logs out in one of them

前端 未结 4 1294
日久生厌
日久生厌 2020-12-01 09:31

I have created Login page, based on localStorage. On loading the page I have checked the value of localStorage. If I opened the web page in more than one tab and then I logo

4条回答
  •  感情败类
    2020-12-01 10:07

    This can also be done with an HTTP header if you are able to set one either in Apache or from a server-side script like PHP:

    Clear-Site-Data: "cookies", "storage", "executionContexts"
    

    E.g. in PHP:

    header('Clear-Site-Data: "cookies", "storage", "executionContexts"');
    

    The key thing to note here is the "executionContexts" directive. From the doc:

    "executionContexts"

    Indicates that the server wishes to reload all browsing contexts for the origin of the response (Location.reload).

    The compatibility in certain browsers (ahem..IE/Edge) is unknown at this time but there is support for this header in most good browsers.

提交回复
热议问题