0

我正在使用 Doctrine 进行 Practical symfony - Jobeet Job Website只是想了解后端的工作原理,我试图覆盖前端和后端中的 isAuthenticated() 函数,我所做的很简单,在我的应用程序\前端\库中\myUser.class.php 文件,我做了这个公开

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\backend\lib\myUser.class.php 中为后端做了同样的事情,但使用is_admin,直到现在一切都很完美,只是在后端,当我要编辑作业时,会话中的sfGuardSecurityUser得到丢失,为什么,因为在此页面中调用的 isAuthenticated() 函数位于 apps\frontend\lib\myUser.class.php 中,所以当我尝试更改页面时,我退出了,因为 isAuthenticated()调用的函数位于apps\backend\lib\myUser.class.php,听起来很少见,但它只发生在Jobs的编辑页面,现在我被困在这里,希望大家理解我,并且更多具体来说,当我进入作业/编辑页面并在操作中放置一个print_r($_SESSION)时,我可以看到这篇文章

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

但是如果我重新加载页面,我就再也看不到这块了,所以,当我尝试更改页面时,我会退出,如果我评论或从 apps\frontend\lib\myUser 中删除 isAuthenticated,我会退出。 class.php 后端的一切都很完美,但我需要覆盖后端和前端的函数

需要一些帮助

谢谢

4

1 回答 1

0

尝试在您的应用程序中设置确切的会话名称factories.yml

all:
  storage:
      class: sfSessionStorage
      param:
        session_name: my_session_name
        session_cookie_domain: example.com
于 2011-04-05T03:44:14.553 回答