Avatar of tyuret
tyuret
 asked on

php session variables

Can I change the value of a session variable (eg: $_SESSION['test']) of a specific user when another user runs  a php page (eg:trigger.php)?
PHP

Avatar of undefined
Last Comment
Ray Paseur

8/22/2022 - Mon
COBOLdinosaur

Interaction between users?  That would be a security issue.  I don't think you could cross-pollinate the threads.

 


Cd&
tyuret

ASKER
I should not be a Session variable. It will ok if I can change any global variable  triggered by other user.
SOLUTION
COBOLdinosaur

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
tyuret

ASKER
With the below code I read the session id of the target user from DB, change a session variable of the target user then change back the session id to original? Seems working
What do you think, any problem you see or any improvement?
Thank you.


$session_id_old=session_id();      
      $sql = "SELECT SESSION_ID FROM LOGIN_HISTORY  WHERE LOGIN_ID=$Touser ";
      $res=selectsql($sql);
                  
      $sesuserid=$res["SESSION_ID"];
      
      session_write_close();
      session_id($sesuserid);
      session_start();
      
      $_SESSION['alertses']=1;
      session_write_close();
      session_id($session_id_old);
      session_start();
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
tyuret

ASKER
Ray thank you for your assist.
But still I am curious if there seems a problem with the code
Ray Paseur

We can't tell if there is a problem with the code.  We do not have your data base, nor do we have the rest of your code.  You might be able to use var_dump() to enable you to look at the data.  If your data looks like what you expect at each point in the process, that's a good thing.