dtds8802 2012-09-26 10:20
浏览 49

PHP会话在htaccess重定向条件下消失 - 仅限Chrome

My project hangs on this single issue.

I have this code in my htaccess to implement a flat url system

Options +FollowSymlinks
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/page.php
RewriteRule (.*) page.php?pid=$1 [QSA]

While this code exists I cannot access session variables created on one page on any other page. Even if the pages are static .php pages that do not go through the redirection the sessions disappear. ONly this code somehow prevents sessions.

I have set session cookie path and domain to make sure the realm is correct, but it does not work.

Any help will be appreciated from the bottom of my heart.

The funny thing is it only fails on Chrome.

  • 写回答

3条回答 默认 最新

  • duandan4680 2012-09-30 02:48
    关注

    Per your comment:

    I have set this additional code to make sure the session cookie is in right path and domain. ini_set('session.cookie_domain', '.bostonairporttaxicab.com'); ini_set('session.cookie_path', 'bostonairporttaxicab.com/';);

    I think your cookie_path is wrong. It should not contain the domain name, as the path is the part trailing the domain name. Try setting it to / and see if that fixes it. Maybe Chrome is interpreting it differently than the other browsers, and therefore rejecting your session cookie.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用