Welcome Guest, Not a member yet? Register   Sign In
Session not work on server
#1

[eluser]edidiway[/eluser]
sorry if there is the same topic about this, but I have searched about this problem on codeigniter forum or google with no solution I understood..

I have a problem about my session that I built with CI not work if I uploaded my file on server.
The session works fine only for FF, but not in IE, Chrome, Opera, and Safari. but please note that The session work fine for all browser if I run on my local host

Why this thing can be happened?

someone that can tell me about this, please post on this forum. thanks for the help
#2

[eluser]Krzemo[/eluser]
You could at least show you session settings from config file here, unless you are looking for clairvoyant not problem solution.
#3

[eluser]Narkboy[/eluser]
[quote author="Cshamoh" date="1295661915"]You could at least show you session settings from config file here, unless you are looking for clairvoyant not problem solution.[/quote]

Harsh, but fair.

[quote author="edidiway" date="1295652116"]I have a problem about my session that I built with CI not work if I uploaded my file on server.
The session works fine only for FF, but not in IE, Chrome, Opera, and Safari. but please note that The session work fine for all browser if I run on my local host[/quote]

Odds are, if it works; it works. If you can get it to go in FF, then check your cookie / security settings in the others. You may find the issue there.

CI sessions are stored in cookies; all browsers cope with cookies, but their security restrictions are all different.

/B
#4

[eluser]edidiway[/eluser]
sorry for the long time to me for posting to this thread.

@Cshamoh : I dont setting anything to the session in config.php file.
if you want see the setting from default, this is the code :
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = FALSE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;

@narkboy : yes, on my mind just like yours, I think if the session works, it should works. but the fact, it didnt work. It only works on FF, but not the others.

if its because cookie / security, why when I ran on my localhost it worked fine.

and there is something I confuse :
I tell to some of my friends to run online using chrome browser on their computer, and it works.. hahaa..
why only on my computer didnt work on server but work on localhost. It seems very odds.
if its because my cookie, I think it is impossible thats my cookie setting on IE, Chrome, Safari, and Opera was crashed at the same time. but remember that the cookie works fine if I run on localhost.

thanks for anyhelp again.
#5

[eluser]Narkboy[/eluser]
OK I got lost a little.

It works for you from localhost and remote with FF?
It works for your friends from remote using Chrome?

Sounds like it's your comp. CI doesn't know what browsers loading the page; nor where it's hosted. Get other people to test the online version using a selection of browsers.

Do you have a browser detection system running?

Also, I wasn't suggesting that anything had 'crashed' on your browsers. Some browsers have different security settings for local network sites and internet sites. You can enable cookies in local sites in IE, for example, while preventing them to www sites.

But - CI session is working; you've got issues with broswers + cookies I think.

/B
#6

[eluser]Krzemo[/eluser]
These are not the only setting that might affect different browsers.
There are also
Code:
$config['cookie_prefix']    = "";
$config['cookie_domain']    = "";
$config['cookie_path']        = "/";
some advice cookie domain to have two dots ...
#7

[eluser]toopay[/eluser]
I had experienced same problems few month ago, see here
#8

[eluser]InsiteFX[/eluser]
Try below code.

IE has a problem with the sess_cookie_name:
Code:
$config[‘sess_cookie_name’] = ‘ci_session’;

// change to:
$config[‘sess_cookie_name’] = ‘cisession’;

Phil Sturgeon, sets the cookie parameters like below:
Code:
$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.
Code:
/*
|--------------------------------------------------------------------------
| 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.php
if (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 on
define('BASE_URL', $base_url);
define('BASE_URI', $base_uri);
define('APPPATH_URI', BASE_URI.APPPATH);

// We dont need these variables any more
unset($base_uri, $base_url);

Config.php base_url
Code:
$config['base_url'] = BASE_URL;

InsiteFX
#9

[eluser]Unknown[/eluser]
InsiteFX, I was looking for it

Very good solution for ci_sessions, I followed your steps and now is working in my server and localhost
Great!

Thanks
#10

[eluser]Unknown[/eluser]
I was experiencing the same problem and the only way I solved the issue is fixing the time on the server.
- I checked the time at the server
- It was around 5 hours delay than the original time.
- Fixed the time
- And Bingo it started working fine for me. Smile




Theme © iAndrew 2016 - Forum software by © MyBB