Welcome Guest, Not a member yet? Register   Sign In
IE8 and session problem
#1

[eluser]Ajaxian64[/eluser]
Hi,

I use ci session with database storage.
I use cisession name instead of ci_session

Whenever a user connect I create a session.
Then he chooses one of two possible roles 'client' and 'invite'

I would like to make impossible to load http://mysite/users/connect when a session is running.

Then in my controller "users" I do this
Code:
private function _verif_session_and_redirect() {
        if($this->session->userdata('user_id') != FALSE) {
            $role = $this->session->userdata('role') ;
            if ($role == 'client')
                redirect('clients/home');
            else if ($role == 'invite')
                    redirect('invites/home');
            else {
                redirect('site');
            }

        }
    }

    function connection() {
    
        $this->_verif_session_and_redirect() ;

                // etc ..
         }
I test with Firefox => it works I have the redirection to clients/home (if I'm a client)
I test with Chrome => it works
I test with Safari => it works
I test with IE8 => Don't work I have the connection form....
Do you know why ? If there a bug ?
Thanks
#2

[eluser]Ajaxian64[/eluser]
In fact If I use trace. When I load http://mysite/users/connect on IE8, the session is not recognize.
Then It displays the form view
But when I do a refresh via F5, then It does not reload the form but seems to recognize the session and THEN redirect me to the right place http://mysite/clients/home
And then, if he try from this point to reload http://mysite/users/connect then IE8 does the job as it was intended from the firts time (redirect to http://mysite/clients/home)
#3

[eluser]Ajaxian64[/eluser]
Always KO
But:
In the view that displays the http://mysite/clients/home I have had (just for test) this:
Code:
<?php echo anchor('users/connection','connection'); ?>

Then When I click on it and due to the fact that I have a session running, then IE8 does the right stuff and redirect me to http://mysite/clients/home.

The problem is that the first attempt to load from http://mysite/clients/home, the url http://mysite/users/connection by writing this directly on the browser (I don't know the word in english for this area on which you enter directly the url) then It doesn't work with IE8
#4

[eluser]Ajaxian64[/eluser]
My problem is far more important than described previously.
I set up the code on a real server (previously I was on localhost)

I can connect to my site with Chrome and Opera. But for IE and FireFox it seems there is a problem of session.

For real server I don't what to put on those following set up:
Code:
$config['cookie_prefix']    = "";
$config['cookie_domain']    = "";
$config['cookie_path']        = "/";
$config['cookie_prefix'] => No need (I hope)
$config['cookie_domain'] = 'mysite.com' Is it right ?
But entirely lost on $config['cookie_path'] = "/"; I really don't know how to set up this ...

Some help would be very appreciate ...
#5

[eluser]InsiteFX[/eluser]
This is from PyroCMS and all credit goes to the PyroCMS Team.

application/config/constants.php
Code:
/*
|--------------------------------------------------------------------------
| Docment root folders - Place in application/config/constants.php
|--------------------------------------------------------------------------
| Author: Phil Sturgeon.
|
| These constants use existing location information to work out web root, etc.
|
*/

// Base URL (keeps this crazy stuff 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 localhost.
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);

aplication/config/config.php
Code:
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|    http://www.your-site.com/
|
*/

$config['base_url'] = BASE_URL;

/*
|--------------------------------------------------------------------------
| Cookie Related Variables
|--------------------------------------------------------------------------
|
| 'cookie_prefix' = Set a prefix if you need to avoid collisions
| 'cookie_domain' = Set to .your-domain.com for site-wide cookies
| 'cookie_path'   =  Typically will be a forward slash
|
*/
$config['cookie_domain']    = ($_SERVER['SERVER_NAME'] == 'localhost' ? '' : preg_replace('/^www\./', '', $_SERVER['SERVER_NAME']));
$config['cookie_path']        = BASE_URI;

InsiteFX
#6

[eluser]Ajaxian64[/eluser]
Thanks InsiteFX for your documented reply.
I will try this today as soon as possible.
#7

[eluser]GKenny[/eluser]
I just want to bump this because InsiteFX solution worked like a charm!
#8

[eluser]InsiteFX[/eluser]
Not my solution credit goe's to the PyroCMS Team!

This is from PyroCMS and all credit goes to the PyroCMS Team.

InsiteFX
#9

[eluser]Mat-Moo[/eluser]
Bit of a bump, but this solution also worked for me! (Also removed _ from my session name)




Theme © iAndrew 2016 - Forum software by © MyBB