如何仅为每个用户显示一次php页面

如何仅为每个用户显示一次php页面,php,cookies,session-timeout,session-cookies,Php,Cookies,Session Timeout,Session Cookies,嗨,我有一个php页面,我想显示它只是每个用户一次 我认为这在cookie、会话超时或会话cookie中是可能的 但我不确定 谢谢你的好意:)你回答了自己的问题-设置了一块饼干 // check if they've been here, if they haven't set // a cookie for subsequent visits if($_COOKIE['beenhere']) { setcookie("beenhere", '1'); } else { //

嗨,我有一个php页面,我想显示它只是每个用户一次

我认为这在cookie、会话超时或会话cookie中是可能的

但我不确定


谢谢你的好意:)

你回答了自己的问题-设置了一块饼干

// check if they've been here, if they haven't set
// a cookie for subsequent visits
if($_COOKIE['beenhere']) { 
    setcookie("beenhere", '1');
}
else {
    // where you want them to go if they've seen this page
    header('Location: http://www.example.com/');
有关更多信息:


如果您希望单个用户再也看不到页面,则必须设置cookie的过期时间(请参见上面的链接页面),因为关闭浏览器将消除cookie,正如我上面所设置的那样。

您通过设置cookie回答了自己的问题

// check if they've been here, if they haven't set
// a cookie for subsequent visits
if($_COOKIE['beenhere']) { 
    setcookie("beenhere", '1');
}
else {
    // where you want them to go if they've seen this page
    header('Location: http://www.example.com/');
有关更多信息:


如果希望单个用户再也看不到页面,则必须为cookie设置过期时间(请参见上面的链接页面),因为关闭浏览器将消除cookie,正如我上面所设置的那样。

要在每个用户会话中显示一次页面,可以尝试以下操作

//mypage.php

if(!isset($_SESSION['mypage_view'])
{
     $_SESSION['mypage_view'] = 1;   
} else {
     //check if this is not the first time the page has been viewed
     if(isset($_SESSION['mypage_view'])) {
      //not first time redirect
      header('location: google.com');
      session_write_close();
      exit();
     }
}

要在每个用户会话中显示一次页面,可以尝试以下操作

//mypage.php

if(!isset($_SESSION['mypage_view'])
{
     $_SESSION['mypage_view'] = 1;   
} else {
     //check if this is not the first time the page has been viewed
     if(isset($_SESSION['mypage_view'])) {
      //not first time redirect
      header('location: google.com');
      session_write_close();
      exit();
     }
}

您也可以使用会话

if($_SESSION['sessioned_here'] == null) {
    // just been on this page
} else {
    // visited already. get out

}

您也可以使用会话

if($_SESSION['sessioned_here'] == null) {
    // just been on this page
} else {
    // visited already. get out

}

每个用户会话一次或“永远”一次?您可以设置为每个IP地址只有一个人可以查看它。每个用户会话一次或“永远”一次?您可以设置为每个IP地址只有一个人可以查看它。会话创建cookie,所以实际上您使用cookie会话创建cookie,所以事实上你用的是饼干这很好,我以前也用过。但是,有没有一种方法可以让每个用户都使用它?我有一个$u会话变量,我希望当一个新手用户进来时,显示一个页面。一台计算机可以使用多个会话登录,因此Cookie不是一个选项。有什么帮助吗?这很好,我以前用过。但是,有没有一种方法可以让每个用户都使用它?我有一个$u会话变量,我希望当一个新手用户进来时,显示一个页面。一台计算机可以使用多个会话登录,因此Cookie不是一个选项。有什么帮助吗?