PHP session does not work for ionic app in IOS emulator?

Viewed 151

I am using php backend controllers with Ionic 3 application. Ionic 3 login works perfect with back-end controller and creates session and I store user data in the session variable.
When I access another controller via Ionic 3 after login success,It get destroyed.
I need to keep session data until it destroy on logout.

But the app works completely fine in android.

I am using ios simulator(ios 10.3) on Xcode 8.3.3

Here is my code.

 userInfo={} as UserInfo;

  this.http.post(this.baseUrl+'index.php/login/user_login', credentials, options).
  map(res => res.json()).subscribe(
        data => {

          if(data['status']==true && data['data']['login']==true){

            //Store user Info
            this.userInfo.username=data['data']['user_details']['username'];
            this.userInfo.user_type=data['data']['user_details']['user_type'];
            this.userInfo.user_id=data['data']['user_details']['user_id'];

            this.storage.set('user_info',this.userInfo).then(()=>{
              this.gui_permission();
              this.isLoggedIn=true;
              this.loggedUser=this.user.username;
            });

            this.loading.dismiss();

            this.storage.set('user',this.user.username).then(()=>{
              this.isLoggedIn=true;
              this.loggedUser=this.user.username;
            });

This is how I check the session data in PHP.

//Checking whether user logged or not

public function is_login(){

     $details = $this->session->userdata('username');
     $is_loged_in = $this->session->userdata('loged_in');

     if(!$details || !$is_loged_in) {
         redirect('login');
     }
}

Help me out to solve this problem.

0 Answers
Related