because it says that the code is not defined if it is a variable that I take from the database?

0

I'm trying to access my pc with the ip address, and it normally leaves me, but I install a virual machine on my pc and when I put the ip of the virtual machine I get this error, 3 more errors come out but they are all similar to this, they put problem in the variable code that I use in the session, I work with mvc of codeigniter:

I take the variable code from the database with a getcode () method:

driver code:

 $code = $this->auth_model->getCode($email); 

model code:

  public function getCode($email){
  $this->db->select('roster_position as code');
  $this->db->where('roster_email',$email);
  $data = $this->db->get('ol_roster');
  $response = $data->row();
  $string = substr($response->code,0);

  return $string;
  }

this is line 8, which is the error line

<?php if ($_SESSION['code'] == "workforce" || $_SESSION['code']=="real time analyst") { ?>

This is the error that comes to me:

A PHP Error was encountered
Severity: Notice

Message: Undefined index: code

Filename: layouts/navbar-sidebar.php

Line Number: 8

Backtrace:

File: C:\xampp\htdocs\olPrueba2\application\views\layouts\navbar-sidebar.php
Line: 8
Function: _error_handler

File: C:\xampp\htdocs\olPrueba2\application\controllers\Admin.php
Line: 80
Function: view

File: C:\xampp\htdocs\olPrueba2\index.php
Line: 315
Function: require_once

Someone told me that I could fix it using MY_Controller and putting the session out there but the truth is that I did not understand very well. How could I solve it?

This comes to me when I print what $ _SESSION has:

CODE:

  Array
 (
 [__ci_last_regenerate] => 1522259167
 [user] => katerin.giraldo
 [domain] => CO
 [workstation] => ONWST528
 [email] => [email protected]
 [code] => workforce
 [name] => Lalita Castrillon
  )

In this case, the code is workforce and I'm doing the session like that

  switch ($_SESSION['code']) {
  case 'workforce':
  case 'real time analyst':
    redirect('controllers\Admin');
    break;

  case 'advocate':
    redirect('controllers\Advocate');
    break;

  case 'supervisor':
      redirect('controllers\Sup');
  break;
  case 'shift Manager':
      redirect('controllers\Manager');
  break;

  default:
    # code...
    break;
}
    
asked by user80520 28.03.2018 в 17:02
source

0 answers