Welcome Guest, Not a member yet? Register   Sign In
Session ID
#1

Hi im a newbbie , i need you help or advise , 

im making some report and i need to use the "id" from 
PHP Code:
$this->session->userdata('logged_in'); 

 i check 
$ses= $this->session->userdata('logged_in');
echo '<pre>';
print_r($ses);
and my data is 
[id] => 23
   [username] =>John Doe 


now how i can use this id because i do this and dont show anything 

$ses= $this->session->userdata('id');

echo '<pre>';
print_r($ses);
   
Reply
#2

(01-29-2016, 07:26 AM)morocho1979 Wrote: Hi im a newbbie , i need you help or advise , 

im making some report and i need to use the "id" from 
PHP Code:
$this->session->userdata('logged_in'); 

 i check 
$ses= $this->session->userdata('logged_in');
echo '<pre>';
print_r($ses);
and my data is 
[id] => 23
   [username] =>John Doe 


now how i can use this id because i do this and dont show anything 

$ses= $this->session->userdata('id');

echo '<pre>';
print_r($ses);
   

Your id is stored as an element in the $ses array so to access it you can use $ses['id']
Reply
#3

(This post was last modified: 01-29-2016, 08:15 AM by morocho1979.)

(01-29-2016, 07:38 AM)pdthinh Wrote:
(01-29-2016, 07:26 AM)morocho1979 Wrote: Hi im a newbbie , i need you help or advise , 

im making some report and i need to use the "id" from 
PHP Code:
$this->session->userdata('logged_in'); 

 i check 
$ses= $this->session->userdata('logged_in');
echo '<pre>';
print_r($ses);
and my data is 
[id] => 23
   [username] =>John Doe 


now how i can use this id because i do this and dont show anything 

$ses= $this->session->userdata('id');

echo '<pre>';
print_r($ses);
   

Your id is stored as an element in the $ses array so to access it you can use $ses['id']

no i want to use in my model so i try this 

PHP Code:
 function obtenerListaClientes()
 
   {
 
    
      $this
->db->select('nombre_fantasia,direccion,fono, url');
 
     $this->db->from('clientes,users');
 
     $this->db->where('id_usuario = id AND id_usuario ='$ses);
 
     $clientes $this->db->get();

 
     return $clientes->result(); 

in the controller i add 

$ses= $this->session->userdata('logged_in');

ofcourse no work i dont have any idea thx for the help
Reply
#4

You can use the Session Lib on your model classes. Just load it on your model constructor and then use it the way you do on your controller, but on your model instead.

Got it? Wink
Best regards,
José Postiga
Senior Backend Developer
Reply
#5

(This post was last modified: 01-29-2016, 07:06 PM by freddy.)

well this is mine, please configuration with yours ya


//here is controller
Code:
$id_user=$this->session->userdata('id_user'); //here is my id which is store in variable
$data['images']=$this->model_register->getimagestopright($id_user); //throw your varibale session in this model

//here is model
Code:
function getimagestopright($id_user)
{
   $this->db->where('id_user', $id_user);
   $this->db->select("*");
   $this->db->from("li_user");
   return $this->db->get();
}

Hope this help you
Reply




Theme © iAndrew 2016 - Forum software by © MyBB