Toggle Login/Logout based on if user is already logged in

断了今生、忘了曾经 提交于 2019-12-10 11:41:32

问题


I have a Play! web application. If the user is logged in, I would like to show a "Logout" link in the top menu. If the user is not logged in, I'd like to hide the "Logout" link and show a "Login" link instead. Easy, right? However, I am unable to find information on how to actually do this.

So, how would I go about this? I used the yabe web app as an example. Is there a #{secure.check} equivalent to check if the user has already logged in? What's the easiest way?

Help would be greatly appreciated, this is driving me nuts!


回答1:


Quite simple :

#{if session.connected()}


来源:https://stackoverflow.com/questions/7331142/toggle-login-logout-based-on-if-user-is-already-logged-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!