Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 如何从 sfUser 中获取 id?
如何在 symfony(1.4.17) 中获取当前登录用户的 ID?
我尝试了获取保护用户的东西,但没有用。我只想将当前用户 ID 放在变量中。
只需在登录过程中设置 id 属性
$this->getUser()->setAttribute("id", <your id>);
然后检索它
$this->getUser()->getAttribute("id");