php Sessions 在没有 www 的情况下无法正常工作 [英] php Sessions not work well without www

查看:33
本文介绍了php Sessions 在没有 www 的情况下无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的会话仅适用于子域,例如www. ,没有那个子域就不能工作.

my sessions only work with a sub-domain, e.g. www. ,and do not work without that sub-domain.

例如,当用户登录时.

如果地址不在子域中.打字未登录.

If the address is not on the sub-domain. Typing does not logged in.

我设置了会话 cookie_domain 但它不起作用.

I set session cookie_domain but it did not work.

//我不想通过htaccess重定向,因为子域都有同样的问题

// I do not want to redirect by htaccess Because sub-domains Both have the same problem

推荐答案

我用这个代码解决了这个问题

i solved this probem use this code

session_name("name");
ini_set ("session.cookie_domain", '.domain.com') ;
session_set_cookie_params(0, '/', '.domain.com');
session_start();

这篇关于php Sessions 在没有 www 的情况下无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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