简体   繁体   中英

Losing session variables/cookies only in Chrome [pretty URL's & .htaccess]

this issue has been around and there's a few different versions of it but I'm stumped. First I'll let you know what my setup is...

CodeIgniter install Works fine on all browsers except chrome... I've narrowed the problem down to pretty URL's and .htaccess sessions are stored in DB

Basically if I use codeigniter's default bootstrap structure index.php/controller it works fine but when I use a mod rewrite .htaccess the sessions get lost, only in chrome.

Some of the things I saw out there, that i've tried...

favicon.ico in root http://bit.ly/UFsYjj and bit.ly/JPUzub

Switching to cookies and setting paths bit.ly/JPUzub

for me it really boils down to the fact that the htaccess removal of index.php is causing the session issue. my codeigniter settings are as follows(note* if tried all different configurations of these settings like no domain etc.):

$config['sess_cookie_name']     = 'cisession';
$config['sess_expiration']      = 99999;
$config['sess_expire_on_close'] = TRUE;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']      = 'ci_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent'] = FALSE;
$config['sess_time_to_update']  = 300;

$config['cookie_prefix']    = "";
$config['cookie_domain']    = ".mydomain.com";
$config['cookie_path']      = "/";
$config['cookie_secure']    = FALSE;

And my htaccess was as follows(now it's currently blank...):

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteEngine on
RewriteCond $1 !^(index\.php|assets|images|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ index.php/$1 [L]

RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php



</IfModule> 

尝试将会话过期时间设置为零。

$config['sess_expiration'] = 0;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM