2012-06-06 59 views
1

我最近將我的網站移至我網站的主要網域。刷新時會話丟失

我發現當我登錄到我的網站時,帳戶頁面顯示,但是當我刷新或進行ajax調用時會話丟失,使我退出。我的帳戶頁面上有一個iframe,我最近剛剛安裝了SSL。

任何想法爲什麼我的會話正在丟失?或者有什麼方法可以找到錯誤類型?

我的PHP的信息是:

session.auto_start Off Off 
session.bug_compat_42 On On 
session.bug_compat_warn On On 
session.cache_expire 180 180 
session.cache_limiter nocache nocache 
session.cookie_domain no value no value 
session.cookie_httponly Off Off 
session.cookie_lifetime 0 0 
session.cookie_path//
session.cookie_secure Off Off 

的錯誤,我得到的,當我把錯誤報告是:

<b>Notice</b>: Undefined index: adminsess in <b>/home/onclick1/public_html/admin.php</b> on line <b>35</b><br /> 
<br /> 
<b>Notice</b>: Undefined index: secure in <b>/home/onclick1/public_html/admin.php</b> on line <b>36</b><br /> 
<br /> 

,使該錯誤是簡單的代碼:

<?php 
session_start(); 
ini_set('error_reporting', E_ALL); 
require "connectTo/db.php"; 

if(!isset($_SESSION['adminsess']) || !isset($_SESSION['secure'])){ 
     //exit(); *comment out to give error* 
    } 

我已經通過我的代碼,發現錯誤似乎只發生(無法存儲會話數據),當我添加啊eader()在索引頁面上重定向。該代碼,我在網站上重定向誰已登錄用戶低於:

如果使用重定向頭..它只是循環和犯規加載頁面

<?php 
session_start(); 

error_reporting(E_ALL | E_WARNING | E_NOTICE); 
ini_set('display_errors', TRUE); 

//print_r($_SERVER); 

//exit; 
$TheIp=ip2long($_SERVER['REMOTE_ADDR']); 
$ip= trim($TheIp); 


include('mobile.php'); 
require "db.php"; 

$_SESSION['secureip'] = $ip; 

if(isset($_SESSION['adminsess'])) 
    { 
    $ipVistor = $ip; 
    $ipVistorSalt= $ipVistor."28257esfgs"; 
    $ip=md5($ipVistorSalt); 

    $userAgent=$_SERVER['HTTP_USER_AGENT']; 
    $userAgentSalt=$userAgent."jk2hgkj22352523s"; 
    $agent=md5($userAgentSalt); 

    if(isset($_SESSION['secure']) && $_SESSION['secure']==$ip) 
    { 

    if (isset($_SESSION['secure2']) && $_SESSION['secure2'] == $agent) 
    {  
     //header("Location: https://www.site.com/admin?Welcome"); 
     exit(); 
    } 
    } 
    } 

?> 

任何幫助/信息將是大。提前致謝 !


即使我把這個在它改掉加載index2.php頁面的最頂端,但只是不斷循環...這是一個服務器的問題? (index2只是索引的一個副本)。

<?php 
header("Location: https://www.site.com/index2.php"); 
exit; 
+1

請發佈PHP代碼。 –

+1

我認爲這裏還有另一個問題,可能是因爲你設置會話的方式或你如何使用它,所以PHP代碼是非常需要的。特別是因爲iFrame可能會介入並且你粘貼的錯誤在沒有代碼的情況下是沒有意義的。 – Toote

+0

'iframe'的用途是什麼? –

回答

1

嘗試更改會議名稱:

session_name("foo"); 

還是在運行時配置:

session.name foo 

確保你調用session_start()和Ajax調用不是另一個域。