How to create global variable in php?

Asked

Viewed 75 times

0

I am working with the codeigniter framework completely separate from the front-end. That is, I run the business rules and send a json to the controller. However, I am doing an authentication to allow whether the user will receive the data or not. Since there is no possibility of using Session, I thought of using a global variable that returns true or false. This way, I can check if the user is logged in, and I have this variable throughout the application. How do I make a global variable in codeigniter?

  • 1

    You can use My_controller, with it you put the check function there. And in your Construct, you call the function. $this->function_name();

  • You can post the code of what you tried to do?

  • You can use through a class, and make a public "nome_da_variável"

  • Redis, JWT, database, cookie. Have you tried any of these? Show the authentication you’re doing, make it easy to answer.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.