开发者

Dealing with session in PHP across Linux user accounts

On a Linux-hosted sever, I have the same web app installed on two user's accounts (http://host.com/~linux_user)

开发者_高级运维

As you might guess, I have problems because sessions are shared between user accounts.

From now on, I'll store them as a session array ($_SESSION['linux_user']['my_data']).

Is this a good approach?


You can also get rid of the problem with using a custom session handler, which handles session storage as you want it to : database, memcache...

More info here : http://php.net/manual/en/function.session-set-save-handler.php


"From now on, I'll store as session array $_SESSION['linux_user']['my_data']. Is this a good approach?"

No, as those session variables will only be available in one user account. What you need is a single-sign-on technology, like if you want to stay logged in over multiple domains. For example you may use OpenID.

Or you store the PHP-session at an explicit location (within the filesystem or in a database).

But why/how do you have the PHP-app installed into two different user accounts? If I set up an Apache web-server, it runs as a separate user…

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜