Link to home
Start Free TrialLog in
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)?
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

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

 


Cd&
Avatar of tyuret
tyuret

ASKER

I should not be a Session variable. It will ok if I can change any global variable  triggered by other user.
SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 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();
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tyuret

ASKER

Ray thank you for your assist.
But still I am curious if there seems a problem with the code
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.