على تطبيق مبرمج بـ codeigniter لدي متحكمين (Controllers) كالآتي:
1-connect facebook
2-connect create
وذلك أن صفحة connect_facebook.php تتيح للمستخدم الدخول وتسجيل بياناته على Session وبالتالي إرسالها -البيانات- إلى connect_create.php. المشكل أن هذه البيانات لا أتمكن من الحصول عليها داخل المتحكم الثاني من قبل Session.
connect facebook:
<?php
/*
* Connect_facebook Website
*/classConnect_facebookextendsWebsite{/**
* Constructor
*/function __construct(){
parent::__construct();// Load the necessary stuff...
$this->load->config('account');
$this->load->helper('form');
$this->load->helper(array('language','ssl','url'));
$this->load->library(array('authentication','facebook_lib'));
$this->load->model(array('account_model','account_facebook_model'));
$this->load->language(array('general','sign_in','account_linked','connect_third_party'));}function index(){// Enable SSL?
maintain_ssl($this->config->item("ssl_enabled"));// Check if user is signed in on facebookif($this->facebook_lib->user){// Check if user has connect facebook to a3mif($user = $this->account_facebook_model->get_by_facebook_id($this->facebook_lib->user['id'])){// Check if user is not signed in on a3mif(!$this->authentication->is_signed_in()){// Run sign in routine
$this->authentication->sign_in($user->account_id);}
$user->account_id === $this->session->userdata('account_id')? $this->session->set_flashdata('linked_error', sprintf(lang('linked_linked_with_this_account'), lang('connect_facebook'))): $this->session->set_flashdata('linked_error', sprintf(lang('linked_linked_with_another_account'), lang('connect_facebook')));
redirect('users/account_linked');}// The user has not connect facebook to a3melse{// Check if user is signed in on a3mif(!$this->authentication->is_signed_in()){// Store user's facebook data in session
$this->session->set_userdata('connect_create', array(array('provider'=>'facebook','provider_id'=> $this->facebook_lib->user['id']), array('fullname'=> $this->facebook_lib->user['name'],'firstname'=> $this->facebook_lib->user['first_name'],'lastname'=> $this->facebook_lib->user['last_name'],'gender'=> $this->facebook_lib->user['gender'],'email'=> $this->facebook_lib->user['email'],// not a required field, not all users have it set'picture'=>'http://graph.facebook.com/'. $this->facebook_lib->user['id'].'/picture/?type=large'// $this->facebook_lib->user['link'])));// send this data to the user submit form
$data['locale']= $this->facebook_lib->user['locale'];
$data['session']= $this->session->userdata('connect_create');
$data['facebook_id']= $this->facebook_lib->user['id'];
$data['username']= $this->facebook_lib->user['name'];
$data['gender']= $this->facebook_lib->user['gender'];
$data['email']= $this->facebook_lib->user['email'];
$this->view('site/connect_create', $data);}else{// Connect facebook to a3m
$this->session->userdata('account_id');
$this->session->set_flashdata('linked_info', sprintf(lang('linked_linked_with_your_account'), lang('connect_facebook')));
redirect('user/account_linked');}}}// Load facebook redirect view
$this->load->view("site/redirect_fb");}}
connect create:
classConnect_createextendsWebsite{/**
* Constructor
*/function __construct(){
parent::__construct();// Load the necessary stuff...
$this->load->config('account');
$this->load->helper(array('language','ssl','url'));
$this->load->library(array('authentication','form_validation'));
$this->load->model(array('account_model','account_details_model','account_facebook_model'));
$this->load->language(array('general','connect_third_party'));}/**
* Complete facebook's authentication process
*
* @access public
* @return void
*/function index(){// Enable SSL?
maintain_ssl($this->config->item("ssl_enabled"));// Redirect user to home if sign ups are disabledif(!($this->config->item("sign_up_enabled"))) redirect('tttt');// Redirect user to home if 'connect_create' session data doesn't existif(! $this->session->userdata('connect_create')) redirect('bbbbbb');
$data['connect_create']= $this->session->userdata('connect_create');// Setup form validation
$this->form_validation->set_error_delimiters('<span class="field_error">','</span>');
$this->form_validation->set_rules(array(array('field'=>'connect_create_username','label'=>'lang:connect_create_username','rules'=>'required'), array('field'=>'connect_create_email','label'=>'lang:connect_create_email','rules'=>'trim|required|valid_email|max_length[160]')));// Run form validationif($this->form_validation->run()){// Check if username already existif($this->username_check($this->input->post('connect_create_username', TRUE))=== TRUE){
$data['connect_create_username_error']= lang('connect_create_username_taken');}// Check if email already exist
elseif ($this->email_check($this->input->post('connect_create_email'), TRUE)=== TRUE){
$data['connect_create_email_error']= lang('connect_create_email_exist');}else{// Destroy 'connect_create' session data
$this->session->unset_userdata('connect_create');// Create user
$user_id = $this->account_model->create();// Add user details
$this->account_details_model->update($user_id, $data['connect_create'][1]);// Connect third party account to userswitch($data['connect_create'][0]['provider']){case'facebook':
$this->account_facebook_model->insert($user_id, $data['connect_create'][0]['provider_id']);break;}// Run sign in routine
$this->authentication->sign_in($user_id);}}
$this->load->view('site/connect_create', isset($data)? $data : NULL);}
السؤال
Badraoui
على تطبيق مبرمج بـ codeigniter لدي متحكمين (Controllers) كالآتي:
1-connect facebook
2-connect create
وذلك أن صفحة connect_facebook.php تتيح للمستخدم الدخول وتسجيل بياناته على Session وبالتالي إرسالها -البيانات- إلى connect_create.php. المشكل أن هذه البيانات لا أتمكن من الحصول عليها داخل المتحكم الثاني من قبل Session.
ما سبب ذلك؟ وكيف أحلّ المشكل؟
1 جواب على هذا السؤال
Recommended Posts
انضم إلى النقاش
يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.