0

How can I unset the SESSION when I close the page by clicking [x] (not onunload). I want to insert when opening the page and when closing, but I don't want to insert when refreshing.

if (!isset($_SESSION["visits"]))
    $_SESSION["visits"] = 0;
    $_SESSION["visits"] = $_SESSION["visits"] + 1;
if ($_SESSION["visits"] > 1){echo "You hit the refresh button!";}
else{
    mysql_query(
        "INSERT INTO najd_visit( visit_userId, visit_staticId, visit_page,
            visit_enterTime)VALUES ('$userId', '$Sid', '$title', '$date') ");
    echo "This is my site";
    //unset($_SESSION["visits"]);
}
4

1 回答 1

0

通过将会话 cookie 的过期时间设置为 0,它会在浏览器完全关闭时自动清除。

这不是您想要的(如果整个浏览器关闭,它只会清除会话),但它应该足够好。

于 2012-05-27T21:31:54.000 回答