Welcome Guest, Not a member yet? Register   Sign In
Login, it works only on Firefox
#1

[eluser]Alhazred[/eluser]
I'm developing an application which requires a login.
On Firefox I have no problem, now I'm trying it on Chrome and Internet Explorer.
When I submit the login form a success page is shown, in this page I have a link which should send me back to the home page, but showing different content.
The link works, but the home page is shown as I'm not logged in.

Of course to know if someone is logged in I use the session, there can be any problem with the session?
How to solve it?

Some code: at the moment in the home view I call 2 views, 1 for the login/logout form and 1 for the menu

login/logout: IE and Chrome always show the login, FF shows correctly the login or logout
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$log = $this->session->userdata('logged');
  
if ( $log !== FALSE && $log == $this->config->item('auth_logged'))
{
//shows logout form
}
else
{
//shows login form
}

menu: IE and Chrome always show the register link, FF correctly shows the user/admin/register links
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$log = $this->session->userdata('logged');

if ( $log !== FALSE &&
     $log == $this->config->item('auth_logged') &&
     $this->session->userdata('level') == $this->config->item('auth_user'))
{
  //show user menu
}
else if ( $log !== FALSE &&
     $log == $this->config->item('auth_logged') &&
     $this->session->userdata('level') == $this->config->item('auth_admin'))
{
  //show admin menu
}
else if ( ! $log)
{
  //show register link
}
#2

[eluser]Alhazred[/eluser]
I add some configuration's settings
Code:
if(isset($_SERVER['HTTP_HOST']))
{
    $config['base_url'] = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http';
    $config['base_url'] .= '://'. $_SERVER['HTTP_HOST'];
    $config['base_url'] .= isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != '80' ? ( ':'.$_SERVER['SERVER_PORT'] ) : '';
    $config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
}
else
{
    $config['base_url'] = 'http://localhost/';
}

$config['sess_cookie_name']  = 'crdsession';
$config['sess_expiration']  = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = TRUE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name']  = 'crd_sessions';
$config['sess_match_ip']  = TRUE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;

$config['cookie_prefix'] = "";
$base_url_parts    = parse_url($config['base_url']);
$config['cookie_domain'] = $base_url_parts['host'];
$config['cookie_path']  = $base_url_parts['path'];
unset($base_url_parts);
$config['cookie_secure'] = FALSE;
#3

[eluser]Alhazred[/eluser]
It looks to be a cookie problem.
I've deleted any browsing data from IE and Chrome before to try this:
I've done the login procedure, 'login success' message appears, I go back to the home page where I've put a
print_r($_COOKIE)

IE and Chrome shows an empty array, FF the correct content for it.

Printing
print_r($this->session->all_userdata())
IE and Chrome show

Array ( [session_id] => 969d9d1306bcce9727766275d55b2fb3 [ip_address] => 127.0.0.1 [user_agent] => Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0) [last_activity] => 1345196493 [user_data] => )

Nothing can be put in ['user_data'] because the session is regenerated on each page change/refresh since it is not recognized as existing.
The database entry for the session is generated, so it seems that everything is an issue with the cookies.

Any idea about how to solve?
#4

[eluser]jotorres1[/eluser]
This has always been a problem within codeigniter using their sessions. What I did was revert back to PHP Sessions and created my own class.
#5

[eluser]DarkManX[/eluser]
Post your login-method. ty




Theme © iAndrew 2016 - Forum software by © MyBB