Figuring out session variables? Having a problem

Hi Everyone,

I’m a little confused by sessions.

This is my goal. In the below URL If someone clicks on “contact us” and they aren’t logged in I want that user to be re-directed to a login page. I know I can do this with php sessions but I’m a confused as to how. Does the session have to be on the car-display-contact2.php or the car-display-contact-update.php? or both pages?

How would you attack this problem?

Thanks everyone!

When someone logs in to your site, put something in their session so that you know they’re logged in on future requests. For example:

//login.php, after you check the username/password or whatever is required
$_SESSION['logged_in'] = 1;

In your car-display-update-contact.php page:

if (!isset($_SESSION['logged_in'])) {
  //redirect to login page