Remove a cookie

后端 未结 22 1627
没有蜡笔的小新
没有蜡笔的小新 2020-11-22 16:16

When I want to remove a Cookie I try

unset($_COOKIE[\'hello\']);

I see in my cookie browser from firefox that the cookie still exists. How

22条回答
  •  星月不相逢
    2020-11-22 16:52

    You could set a session variable based on cookie values

    session_start();
    
    if(isset($_COOKIE['loggedin']) && ($_COOKIE['loggedin'] == "true") ){
    $_SESSION['loggedin'] = "true";
    }
    
    echo ($_SESSION['loggedin'] == "true" ? "You are logged in" : "Please Login to continue");
    

提交回复
热议问题