Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

towhid's avatar

how to data save in session time , globally ?

i am login from third party API , login time i collect one serial key , every others api data read need this serial key , logout time the serial key will delete .

how i do that ?

0 likes
7 replies
towhid's avatar

@Yorki i want to achive this thing - : i want to save data in session globally , its mean where i want to use those data then call there-

thank you

Snapey's avatar

You cannot use session if it is for more than one user? Session is user specific

Its unclear what 'globally' means in your case?

1 like
towhid's avatar

@Snapey hello , , you are right , i want to keep token every user login time -- when any user access login then create one serial from api jasson data , i just keep this token one variable on time i keep this token till logout in globally , i just want to use this token every route time till log out this user . after log out the session data delete .

Yorki's avatar

Maybe additional field like token in your users table is the way to go. When user logins you just update his token in database. Then each request you can query database about existance of that token and who it belongs to. At logout time you just clear it.

towhid's avatar
towhid
OP
Best Answer
Level 5

the answer is -- if i need to carry the session then every single session have to save - like

$variableName = session('token');

the when we have to need then first check the session like -

 if (!empty($variableName))
{
//
}else{
//
}

thanks all of you ..

1 like

Please or to participate in this conversation.