spearchilduser Posted January 27, 2012 Share Posted January 27, 2012 Im makigna simple login system for a sight but i only want them to have to login if they want to go to the shopping cart i have t implement a session_start() on every page before the cart page so the home page products page etc etc and then on the cart page ive a simple function that checks if their logged in if not then it will direct them to the login page if they are they should just continue is this the correct way to do it ? thanx Quote Link to comment https://forums.phpfreaks.com/topic/255875-sessions/ Share on other sites More sharing options...
AyKay47 Posted January 27, 2012 Share Posted January 27, 2012 Perhaps if you could explain your logic more in detail. What exactly are you planning to store in sessions to check if the user is logged in? Remember, sessions can expire after a certain timeframe if you do not have your settings set correctly. Quote Link to comment https://forums.phpfreaks.com/topic/255875-sessions/#findComment-1311634 Share on other sites More sharing options...
spearchilduser Posted January 27, 2012 Author Share Posted January 27, 2012 i was just looking to store if the user has logged in or not Quote Link to comment https://forums.phpfreaks.com/topic/255875-sessions/#findComment-1311636 Share on other sites More sharing options...
trq Posted January 27, 2012 Share Posted January 27, 2012 That would be as simple as.... // authenticate the user if ($authenticated) { $_SESSION['loggin-in'] = true; } Then to check to see if they are logged in. if (isset($_SESSION['logged-in'])) { // do whatever } Quote Link to comment https://forums.phpfreaks.com/topic/255875-sessions/#findComment-1311641 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.