0

i have some question in Codeigniter session class:

  1. whats different between these

    $this->session->all_userdata(); 
    $this->session->userdata
    

    both of them return array of all user data in ci session (cooke).

  2. and why this code is wrong:

    $this->session->userdata();
    

    but this one is correct:

    $this->session->userdata
    

    why?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Majid
  • 35
  • 1
  • 7

1 Answers1

0

for 1: $this->session->all_userdata(); is method to get CI-session's data $this->session->userdata is variable of CI-session's class, You shouldn't get session's data this way.

for 2: $this->session->userdata(); is correct because this way You'll use setters-getters mechanism (read more here), $this->session->userdata is incorrect because You try to get data directly (read link above to get more info)

Community
  • 1
  • 1
Egor Sazanovich
  • 4,979
  • 5
  • 23
  • 37