frijole Posted February 14, 2008 Share Posted February 14, 2008 I do not yet understand how the [session] variable works yet. I want to be able to tell all the pages on the site that the user is logged in so that specific items can be shown, or not shown. Is this the right direction for me to look to figure this out? Link to comment https://forums.phpfreaks.com/topic/91148-how-can-you-inform-the-web-app-that-a-user-is-already-logged-in/ Share on other sites More sharing options...
p2grace Posted February 14, 2008 Share Posted February 14, 2008 You set a session upon logging in and save that users id in a session variable. Then just check if that session variable exists before showing any content. Link to comment https://forums.phpfreaks.com/topic/91148-how-can-you-inform-the-web-app-that-a-user-is-already-logged-in/#findComment-467199 Share on other sites More sharing options...
frijole Posted February 15, 2008 Author Share Posted February 15, 2008 how can you transfer that variable to a new page? Link to comment https://forums.phpfreaks.com/topic/91148-how-can-you-inform-the-web-app-that-a-user-is-already-logged-in/#findComment-467882 Share on other sites More sharing options...
craygo Posted February 15, 2008 Share Posted February 15, 2008 You have to use session_start(); on every page you use. When someone logs in you can store it. $_SESSION['login'] = 1; $_SESSION['username'] = $namevariable; Now anytime you want to know the person who is logged in just call the session variable echo $_SESSION['username']; if you want to check use something like <?php if($_SESSION['login'] == 1){ //page content here echo "welcome ".$_SESSION['username']; } else { echo "you are not logged in } ?> Ray Link to comment https://forums.phpfreaks.com/topic/91148-how-can-you-inform-the-web-app-that-a-user-is-already-logged-in/#findComment-467906 Share on other sites More sharing options...
frijole Posted February 15, 2008 Author Share Posted February 15, 2008 awesome, that was very clear. Thank You. Link to comment https://forums.phpfreaks.com/topic/91148-how-can-you-inform-the-web-app-that-a-user-is-already-logged-in/#findComment-467915 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.