How to avoid unwanted session carry-over between different instances of an application

痴心易碎 提交于 2019-12-11 11:51:11

问题


Scenario

I have the local version of a Zend Framework application open in one Chrome tab (development environment). At the same time I have the stage or live version of the same application running on a remote server open as well. I'm logged in one of the instances. When I try to log in to the other, this instance exits with a fatal error until I delete the cookies of the other instance, where I'm logged in first.

The domain setting on the session cookies is not identical but the carry-over still happens.

Questions

Why does that happen?
How can I avoid it?


回答1:


Give each server a different session name (not the default one), so that you have different sessions. This does normally work if you want to use multiple sessions next to each other (and you don't want to check the cookie settings like taking care cookie works in it's domain only and that next to cookie nothing else is used to pass the ID).

In native PHP it's session_name, I assume Zend Framework has a corresponding configuration setting as well.




回答2:


What is the domain setting on the session cookies for both? If it's a top level one, like .example.com, then the cookie'll be shared across both systems. You could nail it down to local.example.com and remote.example.com so the session cookies are distinct and won't overlap.



来源:https://stackoverflow.com/questions/9098861/how-to-avoid-unwanted-session-carry-over-between-different-instances-of-an-appli

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