一个关于cookie的问题,大家帮忙看看!

txh771208 2004-08-03 07:04:36
我设置了cookie以后只能传到一个页面啊,别的页面再调用,就不行了,不知道是什么问题?还有我用$_SERVER{"HTTP_REFERER"]这个取得了上一页的网址,登陆以后就返回上一页,cookie怎么也传不过去啊?高手帮忙啊!谢谢!
...全文
152 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuzuning 2004-08-04
  • 打赏
  • 举报
回复
1、贴出你的代码,不要让人去猜你是如何写的!
2、cookie默认doamin为/。即cookie在同一浏览器进程中对网站所有的页面有效
txh771208 2004-08-04
  • 打赏
  • 举报
回复
如果整个站点好多文件都要用到cookie,而又不在一个文件夹下,应该怎么设啊?
txh771208 2004-08-04
  • 打赏
  • 举报
回复
不是浏览器设置的问题
txh771208 2004-08-04
  • 打赏
  • 举报
回复
<?setcookie("user",$username);
setcookie("right",mysql_result($result,0,'qx'));
setcookie("workname",mysql_result($result,0,'workname'));?>
<script language=javascript>
window.location.href='<?=$HTTP_SERVER_VARS['HTTP_REFERER'];?>';
</script>
我把生成cookie的文件放到跟目录下去了,cookie可以用了。现在的问题是我在我的机子上可以用,到别人的机子怎么也用不了啊!
ice_berg16 2004-08-03
  • 打赏
  • 举报
回复
设置cookie的页面和访问cookie是否在同一目录下?
如果不是请在设置cookie时设置cookie的有效路径
bool setcookie ( string name [, string value [, int expire [, string path [, string domain [, int secure]]]]])

path
If set to '/', the cookie will be available within the entire domain. If set to '/foo/', the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain. The default value is the current directory that the cookie is being set in.
aspczlover 2004-08-03
  • 打赏
  • 举报
回复
cookie只有在同一个应用程序里(同一个站点)有效
unixdotnet 2004-08-03
  • 打赏
  • 举报
回复
你调用setcookie后有没有提示设置失败?

你在其它页面是怎么读取cookie变量的?

最好用$_COOKIE['key']方式获取
txh771208 2004-08-03
  • 打赏
  • 举报
回复
自己先顶一下!

21,893

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧