使用 phpfog 托管时,codeigniter 会话丢失会话状态
我已经构建了一个 php/codeigniter 应用程序,当我在 vps 上使用rackspace 托管它时,它运行得非常好。我最近将其迁移到 phpfog 的托管环境,但是我遇到了用户会话的问题。
我正在使用会话类将数据存储在数据库中。我看到的问题是,在初始页面请求中,在数据库中创建了两个会话记录。然后对于每个页面请求,都会创建一个新的会话记录。当从一个页面转到另一个页面时,应用程序会丢失其会话。
我不确定是什么原因造成的,也许是缓存层或 phpfog 的负载均衡器?有什么想法吗?谢谢!
更新:
在玩了相当长一段时间后,我可能已经能够将这个错误跟踪到我的 CSS 文件之一中包含的 @font-face ??????
/*
@font-face {
font-family: 'ColaborateLightRegular';
src: url('/application/assets/web/css/fonts/ColabLig-webfont.eot');
src: url('/application/assets/web/css/fonts/ColabLig-webfont.eot?iefix') format('eot'),
url('/application/assets/web/css/fonts/ColabLig-webfont.woff') format('woff'),
url('/application/assets/web/css/fonts/ColabLig-webfont.ttf') format('truetype'),
url('/application/assets/web/css/fonts/ColabLig-webfont.svg#webfontR2xcGGVv') format('svg');
font-weight: normal;
font-style: normal;
}
*/
当我的许多网站页面上包含的样式表中没有注释掉该代码块时,就会在我的数据库中创建一个新会话。当它被注释掉时,新的会话不会发生?明天我会进一步研究一下,因为现在我正在睡觉,但这很奇怪。有谁知道可能是什么原因造成的?
I've built a php/codeigniter app which worked perfectly when I hosted it with rackspace on a vps. I've recently migrated it over to phpfog's hosting environment however I'm running into an issue with my user's sessions.
I'm using the sessions class to store data in the database. The problem I'm seeing is that on the initial page request, two session records are created in the database. And then for every page request following that a new session record is created. The application loses its session when going from page to page.
I'm not sure what could be causing this, maybe the cache-layer or the load balancer of phpfog? Any ideas? Thanks!
UPDATE:
After playing around with this for quite some time I might have been able to track this bug down to a @font-face include in one of my CSS files????????
/*
@font-face {
font-family: 'ColaborateLightRegular';
src: url('/application/assets/web/css/fonts/ColabLig-webfont.eot');
src: url('/application/assets/web/css/fonts/ColabLig-webfont.eot?iefix') format('eot'),
url('/application/assets/web/css/fonts/ColabLig-webfont.woff') format('woff'),
url('/application/assets/web/css/fonts/ColabLig-webfont.ttf') format('truetype'),
url('/application/assets/web/css/fonts/ColabLig-webfont.svg#webfontR2xcGGVv') format('svg');
font-weight: normal;
font-style: normal;
}
*/
When that block of code is not commented out in a style sheet included on many of my website's pages, a new session is created in my database. When it is commented out, the new session doesn't occur? I'll look into it a bit more tomorrow because right now I'm falling asleep but this is pretty weird. Does anyone know what might be causing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,我最终确定了导致数据库中出现额外会话的原因。我修改了 codeigniter 以呈现带有控制器和视图的自定义 404 页面,并且该页面导致生成新会话。本质上,我的浏览器会寻找我的服务器上不存在的图像,并且由于浏览器正在请求图像/静态资源,因此它不会为其传递 cookie。然后 404 控制器将启动,并且由于没有传递 cookie,它会假设这是一个新会话并生成一个。很难追踪到的错误。
So I eventually determined what was causing the extra sessions to appear in my database. I had modified codeigniter to render a custom 404 page with a controller and a view, and this page was causing a new session to be generated. Essentially my browser would be looking for an image that didn't exist on my server, and since the browser was requesting an image/static resource it wasn't passing along a cookie for it. The 404-controller would then get initiated and since no cookie was passed it would assume this was a new session and generate one. Pretty tricky bug to track down.