Jump to content

SESSIONS


spearchilduser

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.