Skip to content

Instantly share code, notes, and snippets.

@jeremy5189
Created May 15, 2013 14:19
Show Gist options
  • Save jeremy5189/5584312 to your computer and use it in GitHub Desktop.
Save jeremy5189/5584312 to your computer and use it in GitHub Desktop.
<?php
/******** 登入畫面 login.php ********/
if(empty($_SESSION['login_success']))
$_SESSION['login_success'] = "";
if( $_SESSION['login_success'] == "true" )
{
header("Location: index.php");
exit();
}
/******** 處理登入 login_proc.php ********/
$_SESSION['login_success'] = "true";
/******** 每頁都要 include 的檢查器 ********/
session_start();
if( $_SESSION['login_success'] != "true" || empty($_SESSION['login_success']) )
{
// 取得當前頁面URL
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$nowURL = urldecode($protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
// 傳給login.php
header("Location: login.php?ref=$nowURL");
exit();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment