久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

第一次訪問時顯示不同的頁面

Show different page if first time visit(第一次訪問時顯示不同的頁面)
本文介紹了第一次訪問時顯示不同的頁面的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我發現了一段代碼,如果它是第一次訪問,它會重定向,但是當我嘗試使用它時,它只是停留在那個代碼上.我對cookies及其工作原理不太了解,所以也許你可以幫忙!這是 PHP 代碼:

I found a snippet of code that redirects if it's the first visit, but when I tried to use it, it just stayed at that code. I don't really understand too much about the cookies and how it works, so maybe you can help! Here's the PHP code:

    <?php

    session_start();

    if (isset($_SESSION['FirstVisit'])) {

    $_SESSION['FirstVisit'] = 1;

    header("Location: http://example.com/index.php");

    // Don't forget to add http colon slash slash www dot before!

    }

?>

那么我該如何修復它,如果這是您第一次訪問該網站,它會將您帶到某個頁面,如果不是,則是默認頁面?

So how could I fix it so if it's your first visit to the site it brings you to a certain page, and if not, the default?

推薦答案

您可以使用以下代碼:

<?php
if (!isset($_COOKIE['firsttime']))
{
    setcookie("firsttime", "no", /* EXPIRE */);
    header('Location: first-time.php');
    exit();
}
else
{
    header('Location: site.php');
    exit();
}
?>

它會檢查您是否有名為firsttime"的 cookie如果沒有,它會創建它并重定向到您的 FIRSTTIME 頁面...如果是,它只會將您重定向到該網站...

It will check if you have a cookie named "firsttime" and if not, it will create it and redirect to your FIRSTTIME page... If yes, it will just redirect you to the website...

編輯 2021請不要使用這種舊方法,而是使用框架或更好的代碼.現在 10 歲了.

EDIT 2021 Please don't use this old method and either use a framework or better code. This is 10 years old now.

這篇關于第一次訪問時顯示不同的頁面的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 久久91精品国产一区二区 | 国产日韩欧美在线 | 色眯眯视频在线观看 | 日本不卡一二三 | 精品久久久久久久久久 | 四虎影视1304t| 国产精品国产三级国产aⅴ原创 | 一区二区三区视频在线免费观看 | 99视频精品 | 久久91| 97操操 | 久久久久久久一区二区三区 | 国产精品18毛片一区二区 | 午夜精品一区二区三区在线观看 | 久久综合久久综合久久综合 | 日韩精品免费在线 | 成人黄色av网址 | 免费能直接在线观看黄的视频 | 国产成人在线免费 | 欧美一级在线视频 | 亚洲在线一区 | 欧美日韩黄色一级片 | 91成人在线| 亚洲精品久久久一区二区三区 | 1204国产成人精品视频 | 99精品视频在线观看 | 日本高清视频在线播放 | 免费在线一区二区 | 亚洲国产成人精品久久久国产成人一区 | 午夜影视大全 | 亚洲精品在线播放 | 国产精品久久久久久久一区二区 | 亚洲精品乱码 | 国产精品免费视频一区 | 亚洲欧美精品国产一级在线 | 亚洲成人精 | 国产精品高潮呻吟久久av野狼 | 永久av | 日韩一区二区三区在线 | 一区二区福利视频 | 91av免费版 |