xcali Posted March 3, 2008 Share Posted March 3, 2008 Hi gang Once again i mest up and posted in wrong forum :/. anyway noob question: I browsed through Google, but none of the web pages i visited gave me the answer i am searching for. I have my website. When guests first enter the web page i have a navigation on the top ( theres 3 buttons: home / sign in / logout) What i would like, is to have a check - if the user is already logged in, then display the logout button, otherwise have the button hidden. May i get some pointers on this? Maybe someone knows where i can find a web page that could explain this to me. I'm not sure if it is suppose to be set as a global variable which would be passed from page to page, or a simple php check that would look for a cookie, before loading of the actual html site. Please advise Thank you Quote Link to comment Share on other sites More sharing options...
unsider Posted March 3, 2008 Share Posted March 3, 2008 That's easy to do. Create a script that checks if the user is logged in, and if not, don't display the content. Google it. I'm sure you could find something to help you. Quote Link to comment Share on other sites More sharing options...
p2grace Posted March 3, 2008 Share Posted March 3, 2008 Example: <?php // Check if user is logged in if(isset($_SESSION['uid'])){ // where uid is a session variable being saved upon logging in echo "Logout"; // echo the logout button }else{ echo "Login"; // echo the login button } ?> Very basic example but it should do the trick Quote Link to comment Share on other sites More sharing options...
xcali Posted March 4, 2008 Author Share Posted March 4, 2008 thank you for the answers guys i did find a lot of information about sessions and such and i have a lot to cover what i don't understand though is... are cookies needed if we have everything stored in a session? i mean would u suggest creating both session and a cookie and then pulling info from the cookies (like userid) or saving it in both cookie and the session, or maybe creating only a session ? Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted March 4, 2008 Share Posted March 4, 2008 i only use sessions, and those work fine for me. Quote Link to comment Share on other sites More sharing options...
p2grace Posted March 4, 2008 Share Posted March 4, 2008 Sessions are ideal for security, but if you want the ability for a user to remain logged in after closing the browser then you'll need to use cookies. Quote Link to comment Share on other sites More sharing options...
xcali Posted March 4, 2008 Author Share Posted March 4, 2008 thank you much Quote Link to comment Share on other sites More sharing options...
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.