2011-04-04 71 views
0

我在做實踐symfony與Doctrine - Jobeet工作網站只是想了解後端如何工作,我試圖覆蓋前端和後端isAuthenticated()函數,我什麼確實很簡單,在我的應用程序\前端\ LIB \ myUser.class.php文件,我這樣做公共覆蓋isAuthenticated()在symfony

function isAuthenticated() 
{ 
    return (bool)($this->authenticated && $this->getAttribute('is_customer', false, 'sfGuardSecurityUser')); 
} 

我也覆蓋sfDoctrineGuard的簽到功能,這樣

public function signIn($user, $remember = false, $con = null) 
{ 
    parent::signIn($user, $remember, $con); 
    if($this->authenticated){ 
     $this->setAttribute('is_customer', true, 'sfGuardSecurityUser'); 
    } 
} 

我所做的同樣適用於apps \ backe中的後端nd \ lib \ myUser.class.php,但使用is_admin,直到現在一切都很完美,只是在後端,當我要編輯作業時,會話中的sfGuardSecurityUser會丟失,原因是在這個頁面中調用的isAuthenticated()函數位於apps \ frontend \ lib \ myUser.class.php中,所以當我嘗試更改註銷的頁面時,cuz isAuthenticated()函數被調用在apps \ backend \ lib \ myUser.class.php中,聽起來很少見,但它只發生在喬布斯的編輯頁面上,現在我卡在這裏,希望你們都瞭解我,並且更具體地說,當我走到工作/編輯頁面,並在行動我把print_r($ _ SESSION),我可以看到這件作品

[sfGuardSecurityUser] => Array 
      (
       [user_id] => 1 
       [is_admin] => 1 
      ) 

但是,如果我重新加載頁面,我看不到這一塊了,所以,當我嘗試更改頁面,我退出,以及更多,如果我評論或從apps \ front \ lib刪除isAuthenticated \ myUser.class.php一切都在後臺是完美的,但我需要覆蓋的後端和前端

功能需要一些幫助

感謝

回答

0

嘗試在你的應用程序設置確切的會議名稱factories.yml

all: 
    storage: 
     class: sfSessionStorage 
     param: 
     session_name: my_session_name 
     session_cookie_domain: example.com 
+0

此外,爲後端和fronend設置不同的會話cookie名稱。 – Dziamid 2011-04-05 09:26:42

+0

IT WORKS PERFECT !!!!謝啦兄弟 – 2011-04-05 14:31:15