[英]check if page was redirected or opened directly in php
我可以檢查page2.php
是直接打開還是我從page1.php
重定向
我嘗試使用if(!header_sent()){}
但它沒有用。
請有人幫幫我嗎? 謝謝
當用戶訪問page1.php時創建一個Session變量,然后在page2.php上檢查該會話變量是否存在。 如果是,則從page1.php重定向用戶。
page1.php中:
<?PHP
session_start();
$_SESSION['page1'] = true;
// then the rest of your PHP code
?>
使page2.php:
<?PHP
session_start();
if( $_SESSION['page1'] ) {
$current_referrer = 'page1.php';
}
// then the rest of your PHP code
?>
顯然,這種方法假設您只處理這兩個頁面...希望這會有所幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.