简体   繁体   English

让不同的Symfony 2应用程序使用相同的会话/登录?

[英]Getting different Symfony 2 applications to use the same session/login?

I have four Symfony 2.1 applications, I want them to share the same sessions/login system so that logging in one gets you inside the others. 我有四个Symfony 2.1应用程序,我希望它们共享相同的会话/登录系统,以便登录一个可以让你进入其他应用程序。

All applications are on the same domain and server, thus they get cookies properly. 所有应用程序都在同一个域和服务器上,因此它们可以正确地获取cookie。 For some reason they still don't work exchangeable. 由于某种原因,他们仍然无法交换。 They all have the same secret property specified in properties.yml . 它们都具有在properties.yml指定的相同secret properties.yml

The problem is that after logging into one, going to other applications require you to login again, and if you do that, then you get logged out of the previous application. 问题是登录到一个应用程序后,转到其他应用程序需要您再次登录,如果这样做,那么您将退出以前的应用程序。

How do I get multiple Symfony 2.1 applications on the same server and domain to work with a single login? 如何在同一服务器和域上获取多个Symfony 2.1应用程序才能使用单次登录?

You should configure your session to point to the same storage location, which would be shared for all applications (in case if you use NativeSessionStorage, which is default). 您应该将会话配置为指向相同的存储位置,该存储位置将为所有应用程序共享(如果使用NativeSessionStorage,则为默认情况)。

framework:
    session:
        # ...
        save_path: "/your/shared/sessions/path"

By default save_path is set to %kernel.cache_dir%/sessions - which is relative to your applications. 默认情况下, save_path设置为%kernel.cache_dir%/sessions - 这与您的应用程序相关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM