久久久久久久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)
主站蜘蛛池模板: 久草成人| 极品久久 | 国产成人av在线 | 激情五月综合 | 欧美在线日韩 | 天天久久| 视频一区在线观看 | 久久精品国产一区二区电影 | 久久久蜜桃一区二区人 | 在线视频一区二区三区 | 国产va | 亚洲成人一区二区在线 | 亚欧性视频 | 国产福利资源在线 | 国产精品s色 | 啪一啪在线视频 | 免费黄色成人 | 视频一区在线播放 | 欧美日韩在线免费观看 | 国产成人免费 | 成人自拍视频 | 欧美九九九 | 青青草一区二区 | 国产欧美精品在线 | 夜夜干夜夜操 | 亚洲欧美少妇 | 夜夜爽99久久国产综合精品女不卡 | 国产精品久久久久久吹潮 | 亚洲国产精品久久久久 | 国产精品国产精品国产专区不蜜 | 干狠狠 | 精品国产不卡一区二区三区 | 色综合视频 | 一区二区三区免费 | 亚洲精品成人网 | 亚洲欧美中文日韩在线v日本 | 中文字幕97 | 久久久黄色 | 午夜电影网站 | 国产视频久久久 | 一区二区三区精品视频 |