Welcome Guest, Not a member yet? Register   Sign In
Where to store login information in codeigniter.
#1
Smile 
(This post was last modified: 05-07-2022, 06:36 PM by yoshi.)

Perhaps this is more of a web application topic than codeigniter.

When a user logs in, the session retains the user id, so I can retrieve the entity from the user table in the controller immediately after login as follows.

PHP Code:
// e.g. 'user' model
{
  ["id"]=> string(1"2"
  ["email"]=> string(19"[email protected]"
  ["username"]=> string(30"demo_teacher2"
  ["password_hash"]=> string(60"$2y$10$...."
    :
  ["deleted_at"]=> NULL
 


I have added a variable to "app\Controllers\BaseController" to retain the model data extracted from the login id even if I have moved some controllers.

Here is the problem.
When I move to another controller, the contents of this variable disappear.

With the School Business Management System, for example, the "school" you belong to will never change while you are logged in.

Therefore, I would like to make it a variable to be remembered while I am browsing, but the value of the "user" model and "school" model will disappear.

Should I extract the model I need from the session id each time in the constructor of each controller?
Reply
#2

If you want variables to persist across the entire app save it in a session.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#3

(05-08-2022, 12:55 AM)ignitedcms Wrote: If you want variables to persist across the entire app save it in a session.

thanks ignitedcms-san.

I will study 'session'
Reply
#4

Yes as @ignitedcms mentioned above the Session is the place to save it,
but you could also create a variable in the BaseController and access it using
$this->variable.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(05-08-2022, 01:25 AM)InsiteFX Wrote: Yes as @ignitedcms  mentioned above the Session is the place to save it,
but you could also create a variable in the BaseController and access it using
$this->variable.
thanks, InsiteFX-san

I have more drawers to keep variables globally in my application.
Reply
#6

Take the output of the program once and take a screenshot for the servant and send it so that I can explain your problem
Reply




Theme © iAndrew 2016 - Forum software by © MyBB