Welcome Guest, Not a member yet? Register   Sign In
Store app global variable
#1

Hello,

Is there a solution to store a global dynamic variable for all my app without database ?

For exemple : a token for API. It's generate just one time by the app, and it can be use by all controllers

Thanks for your returns
Reply
#2

@FlorianL,

Yes, you could use session variables (https://codeigniter.com/user_guide/libra...ssion-data).
Reply
#3

(04-26-2021, 07:11 AM)php_rocs Wrote: @FlorianL,

Yes, you could use session variables (https://codeigniter.com/user_guide/libra...ssion-data).
Hi php_rocs,

Thanks for your reply. Session aren't global for my application but only for my client.

For example :
i init an API connexion with an auth processus on the website
The end of this processus give me a token
I want to store this token for all users on my website can use it to interact with the API.

Database is a solution but i think it's not the right to use-it only for store one or two variables
Reply
#4

Use a shared database to store it.
What did you Try? What did you Get? What did you Expect?

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

Try saving a file to the writable folder and allow the file contents to be changed. This would make the variable file contents dynamic. The file name could be an index.php defined constant.
Reply
#6

Jwt token its good choice
I used and work vwry well

First generate jwt token then getbtoken as header authentication finally use filter to validate token if expire or not

Search jwt token for ci4
Enlightenment  Is  Freedom
Reply
#7

You want Cache. If you set TTL (time to live) to 0 it will persist until overwritten or explicitly deleted, though likely if you are receiving an Auth token it will already have its own expiration associated.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB