Welcome Guest, Not a member yet? Register   Sign In
after success login using API facebook not redirect to right controller
#3

(This post was last modified: 11-06-2015, 09:27 PM by freddy.)

hello sorry late respond did you mean add refresh in here ?

Code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Register extends CI_Controller
{
    
    public function index()
    {

        

        
        $data['login_url']= $this->facebook->getLoginUrl(array('redirect_uri' => site_url('register/loginfacebook'),
            'scope' => array( "email, user_birthday, user_location, user_work_history, user_hometown, user_photos"
           )));
          
        $data['login_google'] = $this->googleplus->loginURL();  //login google
        $this->admin->load('template1', 'index', $data);
    }


    public function loginfacebook()
    {
        
        $user = "";
        $userId = $this->facebook->getUser();        
        if ($userId) {
        try {
            $user = $this->facebook->api('/me?fields=id,name,link,email,gender');
            } catch (FacebookApiException $e) {
                $user = "";
            }

        }else {
          
            $this->facebook->destroySession();
        }

         if($user!="")
         {
            $email = $user['email'];
            $q = $this->db->select('email')->from('li_user')->where(array(
                'email' => $email
            ))->get();

             if ($q->num_rows() > 0) {
                   //UPDATE DATA USER
                    $user_details = array(
                        'nama' => $user['name'],
                        'email' => $user['email'],
                        'user_status' => '1'
                    );
                  
                   $this->session->set_userdata('user', $user);  
                   $condition['email'] = $user['email'];
                   $this->model_register->updateuserbyfacebook($user_details,$condition);
            
         //      redirect(site_url('welcome','refresh'));  //this redirect not giving me redirect
    
            }
                else
                 {
                     //INSERT DATA USER
                    $user_details = array(
                        'nama' => $user['name'],
                        'email' => $user['email'],
                        'user_status' => '1'
                    );
                    $this->session->set_userdata('user', $user);      
                    $this->model_register->adduserbyfacebook($user_details);
              
          //     redirect(site_url('welcome','refresh'));
  
                  //  echo "you just insert data";
                }
  redirect(site_url('welcome','refresh'));  //this redirect not giving me redirect
  
        }
         else
         {
            $data['login_url']= $this->facebook->getLoginUrl(array('redirect_uri' => site_url('register/loginfacebook'),
              'scope' => array( "email, user_birthday, user_location, user_work_history, user_hometown, user_photos"
              )));
            $this->admin->load('template1', 'index', $data);
         }

    }

after adding refresh, the page facebook not redirect to welcome the page stay in facebook login without errors, please anyone guide me
Reply


Messages In This Thread
RE: after success login using API facebook not redirect to right controller - by freddy - 11-06-2015, 09:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB