每当我将页面更改为喜欢博客或论坛时,它就会失去会话。然后我点击登录,它有会话,所以它说你已经登录了。支持吗?---> http://www.kdogisthebest.webege.com/
用户名:demouser
密码:demouser
登录.php
<?php session_start(); require_once('connections/Main.php');
if($_SESSION['username']) {
echo '<div class="error_message">Attention! You, '.$_SESSION['username'].' are already logged in.</div>'; echo "<br />"; echo "Go <a target='top' href='index.php'>back</a> to the page you were viewing before this.</li>";
exit(); }
.../// 跳过数据库检查 ///...
// Check that at least one row was returned
$rowCheck = mysql_num_rows($result);
if($rowCheck > 0) {
while($row = mysql_fetch_array($result)) {
// Start the session and register a variable
if(isset($_POST['remmemberme'])){
setcookie(kitbusername, $uesr, time()*24);
}
$_SESSION['username'] = $user;
//session_register('username');
echo '<script> parent.document.location.href = "index.php"; </script>';
} ?>
注销.php
<?php
session_start();
// unset cookies
if (isset($_SERVER['HTTP_COOKIE'])) {
$cookies = explode(';', $_SERVER['HTTP_COOKIE']);
foreach($cookies as $cookie) {
$parts = explode('=', $cookie);
$name = trim($parts[0]);
setcookie($name, '', time()-1000);
setcookie($name, '', time()-1000, '/');
}
}
if($_SESSION['username']) {
session_unset();
session_destroy();
header("Location: index.php"); }
else { header("Location: index.php"); } ?>
头文件.php
<div id="loginoutbox" class="ablack">
<div style="display: inline-block; font-size: 14px; padding-left: 20px;">Hello <?php if($_COOKIE['kitbusername']) { echo $_COOKIE['kitbusername'];} else {echo $_SESSION['username'];} ?>! | </div>
<a id="register" href="http://www.kdogisthebest.webege.com/admin/" class="button">Dashboard</a> |
<a id="signin" href="#fallr-confirmlike" class="button">Logout</a>
<?php }else{ ?>
<div style="display: inline-block; font-size: 14px; padding-left: 20px;">Hello Guest!</div>
<a id="register" href="#fallr-register" class="button">Register</a> |
<a id="signin" href="#fallr-signin" class="button">Login</a>
<?php } ?>
</div>
</div>