JeevaRekha
JeevaRekha

Reputation: 413

How to set cookie based on browser tab

In my application i have set a cookie like

if(!isset($_COOKIE["uk_redirect_flag"])) {
    setcookie("uk_redirect_flag", 1, time() + (86400 * 30), "/"); 
}

so if uk_redirect_flag = 0 I'm showing some flash message. If uk_redirect_flag =1 the flash message wont display. It is working in one tab on firefox. So my problem is when i open another tab on firefox uk_redirect_flag value is still 1. I need to delete the cookie when i open new tab or close tab. How to set cookie value based on browser tab?

Upvotes: 2

Views: 6761

Answers (1)

AleJuliet
AleJuliet

Reputation: 73

That's not possible since a cookie are defined by a path, that means that all browser tabs and windows by one user share the same cookie.

You could try this proposed solution: How to differ sessions in browser-tabs? ir propose to use local storage.

Upvotes: 0

Related Questions