boionfire81 Posted December 10, 2023 Posted December 10, 2023 I'm trying to make it possible to switch between user accounts to view the game as another member other than the super admin/logged in userid. I created this form: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. In globals & sglobals I have: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. It's placed right below the You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. It has 0 effect on which user info is being pulled. What am I missing? 1 Quote
gamble Posted December 10, 2023 Posted December 10, 2023 (edited) From what I'm seeing you're never setting the session "switch_to" but your if statement is checking it. You should have a check for the form that sets the switch_to session Edited December 10, 2023 by gamble Quote
boionfire81 Posted December 10, 2023 Author Posted December 10, 2023 Sorry forgot to include the staff.php edit where its set You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Quote
Uridium Posted December 10, 2023 Posted December 10, 2023 (edited) so you want to switch from being staff to becoming a regular member but be able to go back to being staff once finished ?? using the same user account you could do this You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. just alter the RENAME ME.php to anyname your new file is gping to be called Edited December 10, 2023 by Uridium i have fat fingers Quote
boionfire81 Posted December 10, 2023 Author Posted December 10, 2023 Trying a new way: Main struggle part is globals You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. The server recognizes the $_SESSION['switch_to'] variable, and will echo it. But it still has me logged in and shows me as the admin. And decided to make a staff page which is: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. What I'm trying to do is view as a specific member. What I'm trying to do is view as a specific member. Nevermind, found it. I'm switch from $ir to $user and the $user variable was still pulling the $_SESSION['userid'] Quote
SRB Posted December 11, 2023 Posted December 11, 2023 17 hours ago, boionfire81 said: Trying a new way: Main struggle part is globals if(isset($_SESSION['switch_to']) && !empty($_SESSION['switch_to'])){ if($_SESSION['switch_to'] == 1 && $_SESSION['userid'] == 1){ $_SESSION['switch_to'] = ""; $userid=$_SESSION['userid']; }elseif($_SESSION['switch_to'] == 1 && $_SESSION['userid'] != 1){ $_SESSION['switch_to'] = ""; $userid=$_SESSION['userid']; }else{ $userid=$_SESSION['switch_to']; } }else{ $userid=$_SESSION['userid']; } You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Pretty sure you can replace that clusterfug of code with this: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Quote
Magictallguy Posted January 9, 2024 Posted January 9, 2024 If running on PHP 8.2 and above, you can use null coalescence You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.