Welcome Guest, Not a member yet? Register   Sign In
Error codeigniter generates multiple sessions for the same user
#11

(12-12-2018, 02:25 PM)xaiborweb Wrote: hello thank you for answering, it is not the problem because I have this problem for a long time and tested with all versions of codeigniter 3.x this has just become and I have all the same problem.[/url]

That being the case then the problem is probably not with the framework but with how it is being used. Please show us your code.
Reply
#12

(12-12-2018, 09:47 PM)dave friend Wrote:
(12-12-2018, 02:25 PM)xaiborweb Wrote: hello thank you for answering, it is not the problem because I have this problem for a long time and tested with all versions of codeigniter 3.x this has just become and I have all the same problem.[/url]

That being the case then the problem is probably not with the framework but with how it is being used. Please show us your code.

/application/config/config.php
PHP Code:
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_session';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['cookie_prefix']    = '';
$config['cookie_domain']    = '';
$config['cookie_path']        = '/';
$config['cookie_secure']    = FALSE;
$config['cookie_httponly']     = FALSE
/application/config/autoload.php
PHP Code:
$autoload['libraries'] = array('ion_auth');
$autoload['helper'] = array('form','url','utility_helper','text'); 
/application/config/ion_auth.php
https://drive.google.com/file/d/1OPSPk82...IeWPV/view

/application/libraries/Ion_auth.php
https://drive.google.com/file/d/1SeA1QIa...bEym7/view

/application/controllers/Auth.php
https://drive.google.com/file/d/1RxNX73O...KSpJL/view

/application/models/Ion_auth_model.php
https://drive.google.com/file/d/14XD6eGb...SVDK-/view

to summarize the only thing I need is a simple user registration and login system, and it seemed simple to implement Ion Auth, but if you know another login system for codeigniter that maybe I do not have these problems that I am presenting with the sessions. I would appreciate it also. Thank you for your help for sure it will serve many as I see that codeigniter gives many problems with session.
Reply
#13

The Ion Auth code is well known and widely used. It does not, by itself, produce the problem you describe.

I'm curious about hybridauthlib. (Please don't provide links to code, put it in the post instead.)

How does the "Auth" controller get called?
What does the "Home" controller look like?
Reply
#14

(12-13-2018, 08:11 AM)dave friend Wrote: The Ion Auth code is well known and widely used. It does not, by itself, produce the problem you describe.

I'm curious about hybridauthlib. (Please don't provide links to code, put it in the post instead.)

How does the "Auth" controller get called?
What does the "Home" controller look like?
hello, I put the links to the code because the code was so extensive that it would not let me publish the forum.

I use hybridauthlib to start a session with social networks.
I leave code.

but I insist if my localhost worked fine, I think the problem could be because the server is in Canada and the traffic is of different time zones, or because the cookie expires very fast or something like that I think, just that I am novice in the subject

/application/config/hybridauthlib.php
https://drive.google.com/file/d/1H6i6UBF...P1HV0/view

the original driver changes it to be compatible with Ion Auth and is in this function: /application/controllers/Auth.php
PHP Code:
public function auth($provider)
    {
        try
        {
            
$this->load->library('HybridAuthLib');
            if (
$this->hybridauthlib->providerEnabled($provider))
            {
                
$service $this->hybridauthlib->authenticate($provider);
                if (
$service->isUserConnected())
                {
                    
$user_profile $service->getUserProfile();
                    
$email $user_profile->emailVerified;
                    
$identity $user_profile->displayName;
                    
$avatar $user_profile->photoURL;
                    
$nombre $user_profile->firstName;
                    
$apellido $user_profile->lastName;
                    
$genero $user_profile->gender;
                    
$lenguaje $user_profile->language;
                    if(
$this->ion_auth->social_login($email,$identity)){
                        
redirect('/''refresh');
                    }else{
                        
$this->ion_auth->social_register($identity,$email,$avatar,$nombre,$apellido,$genero,$lenguaje);
                        
$this->ion_auth->social_login($identity,$email);
                        
redirect('/''refresh');
                    }
                }
                else 
// Cannot authenticate user
                
{
                    
show_error('Cannot authenticate user');
                }
            }
            else 
// This service is not enabled.
            
{
                
show_404($_SERVER['REQUEST_URI']);
            }
        }
        catch(
Exception $e)
        {
            
$error 'Unexpected error';
            switch(
$e->getCode())
            {
                case 
$error 'Unspecified error.'; break;
                case 
$error 'Hybriauth configuration error.'; break;
                case 
$error 'Provider not properly configured.'; break;
                case 
$error 'Unknown or disabled provider.'; break;
                case 
$error 'Missing provider application credentials.'; break;
                case 
log_message('debug''controllers.HAuth.login: Authentification failed. The user has canceled the authentication or the provider refused the connection.');
                 
        //redirect();
                 
        if (isset($service))
                 
        {
                 
            log_message('debug''controllers.HAuth.login: logging out from service.');
                 
            $service->logout();
                 
        }
                 
        show_error('User has cancelled the authentication or the provider refused the connection.');
                 
        break;
                case 
$error 'User profile request failed. Most likely the user is not connected to the provider and he should to authenticate again.';
                 
        break;
                case 
$error 'User not connected to the provider.';
                 
        break;
            }
            if (isset(
$service))
            {
                
$service->logout();
            }
            
log_message('error''controllers.HAuth.login: '.$error);
            
show_error('Error authenticating user.');
        }
    }
    public function 
endpoint()
    {
        
log_message('debug''controllers.HAuth.endpoint called.');
        
log_message('info''controllers.HAuth.endpoint: $_REQUEST: '.print_r($_REQUESTTRUE));
        if (
$_SERVER['REQUEST_METHOD'] === 'GET')
        {
            
log_message('debug''controllers.HAuth.endpoint: the request method is GET, copying REQUEST array into GET array.');
            
$_GET $_REQUEST;
        }
        
log_message('debug''controllers.HAuth.endpoint: loading the original HybridAuth endpoint script.');
        require_once 
APPPATH.'/third_party/hybridauth/index.php';
    } 

/application/libraries/HybridAuthLib.php
https://drive.google.com/file/d/1B1u8Oj4...p5dgg/view

thanks for your help
Reply




Theme © iAndrew 2016 - Forum software by © MyBB