PHP sessions disappear in htaccess redirect mode - only in Chrome

My project freezes on this one problem.

I have this code in my htaccess for implementing 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] 

As long as this code exists, I cannot access the session variables created on one page on any other page. Even if the pages are static .php pages that fail redirection, sessions disappear. Only this code somehow prevents sessions.

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

Any help would be appreciated from below my heart.

The funny thing is that it only fails in Chrome.

+4
source share
3 answers

For your comment:

I installed this extra code to make sure the session cookie is in the correct path and domain. ini_set ('session.cookie_domain', '.bostonairporttaxicab.com'); ini_set ('session.cookie_path', 'Bostonairporttaxicab.com/';)

I think your cookie_path is incorrect. It should not contain a domain name, since the path is the part ending the domain name. Try setting it to / and check if it fixes it. Maybe Chrome interprets it differently than other browsers, and therefore rejects your session cookie.

0
source

If it doesn’t work in Chrome, this is your Chrome error ... Browsers could not do anything with .htaccess or SESSION , since they ran on the server side. You should check it from other computers via Chrome, if it works, then this is exactly your Chrome error, that I am somehow sure of this ...

0
source

You started a session on each page.

You will need to write session_start (); function at the top of the file right after php

The Htaccess file does not play a role in the session, as your session variable lives on until your session is active.

0
source

Source: https://habr.com/ru/post/1436341/


All Articles