解法:
http://stackoverflow.com/questions/5783595/codeigniter-session-cookie-domain
http://stackoverflow.com/questions/4268823/codeigniter-cookies-working-in-ff-but-not-chrome-or-ie
http://stackoverflow.com/questions/10131824/codeigniter-session-does-not-work-in-google-chrome
http://codeigniter.com/forums/viewthread/178904/ (採用)
如同上面發言:
Try below code.
IE has a problem with the sess_cookie_name:
$config[‘sess_cookie_name’] = ‘ci_session’;
// change to:$config[‘sess_cookie_name’] = ‘cisession’;
Phil Sturgeon, sets the cookie parameters like below:
$config['cookie_prefix'] = "";$config['cookie_domain'] = ($_SERVER['SERVER_NAME'] == 'localhost' ? '' : preg_replace('/^www\./', '', $_SERVER['SERVER_NAME']));$config['cookie_path'] = BASE_URI;
Phil Sturgeon, also adds this to application/config/constants.php at the bottom.
/*
|--------------------------------------------------------------------------
| Docment root folders
|--------------------------------------------------------------------------
|
| These constants use existing location information to work out web root, etc.
|
*/
// Base URL (keeps this crazy sh*t out of the config.phpif (isset($_SERVER['HTTP_HOST'])){
$base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http';
$base_url .= '://'. $_SERVER['HTTP_HOST'];
$base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
// Base URI (It's different to base URL!)
$base_uri = parse_url($base_url, PHP_URL_PATH);
if (substr($base_uri, 0, 1) != '/')
{
$base_uri = '/'.$base_uri;
}
if (substr($base_uri, -1, 1) != '/')
{
$base_uri .= '/';
}
}
else{
$base_url = 'http://localhost/';
$base_uri = '/';}
// Define these values to be used later ondefine('BASE_URL', $base_url);define('BASE_URI', $base_uri);define('APPPATH_URI', BASE_URI.APPPATH);
// We dont need these variables any moreunset($base_uri, $base_url);
Config.php base_url
$config['base_url'] = BASE_URL;
最後修改這,才成功:
I have Just Changed on line of code and its working perfectly.
change
$config['sess_expiration'] = 7200;
to
$config['sess_expiration'] = 86400;
沒有留言:
張貼留言