同一域上的多个Laravel 5项目 [英] Multiple Laravel 5 projects on the same domain

查看:163
本文介绍了同一域上的多个Laravel 5项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在同一个域的子文件夹中运行了几个Laravel 5项目.

I got several Laravel 5 projects running on subfolders, on the same domain.

每个Laravel应用程序都在生成它自己的会话cookie,有时它生成的内容如此之多,以至于我们在整个域上都遇到http 400错误.

Each Laravel application is generating it's own session cookie, and sometimes it generates so much that we get http 400 errors on the entire domain.

我应该在所有这些项目之间共享存储文件夹,还是有任何设置可以防止这种情况发生?

Should I share the storage folder between all those projects, or there's any settings to prevent that to happen?

推荐答案

自从找到解决方案后,让我与大家分享.

Since I found the solution, let me share with you guys.

首先,您需要使用Redis或数据库之类的共享会话驱动程序.

First, you need to use a shared session driver like Redis or database.

第二,您需要在config/session.php上设置会话cookie和路径相同.

Second, you need to set on config/session.php, the session cookie and path to be the same.

此后,您可以在同一个域上运行多个不同的Laravel项目,而不会出现Cookie问题.

After that, you can run as many different Laravel projects on the same domain without having problems with cookies.

如果您的应用程序根本不需要会话,则可以在app/Http/Kernel.php上完全禁用会话,并注释以下几行:

If your application does not require session at all, you can disable sessions entirelly on app/Http/Kernel.php, commenting the following lines:

\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,

这篇关于同一域上的多个Laravel 5项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆