Jump to content

[SOLVED] Are log in sessions what i'm looking for?


webmaster1

Recommended Posts

Hi All,

 

I'm building a basic CRM for work where I want users to:

 

  • be directed to a specific page based on their log in details.
  • remain logged in (no timing out of session).
     

 

Should I be using sessions for this or do I use something simpler such as the username and password in a php page?

 

Any reccomended tutorials would be apreciated too (yes, I do know how to google, just wondering if there is any specific tutorial some of you would reccomend  :P).

Link to comment
Share on other sites

So you're saying the below code (its functional) would not time out until the browser is closed?

 

<?php
session_start();
    $valid_username = "user";
    $valid_password = "pass";

    $username = isset($_POST['username'])?$_POST['username']:"";
    $password = isset($_POST['password'])?$_POST['password']:"";

    if ($username == $valid_username && $password == $valid_password) {
          $_SESSION['logged'] = true;   
         header("Location: admin.php");
    }else {
             $_SESSION['logged'] = false;
             header("Location: loginfl.php");
    }?>

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.