0

I m new in PHP Programming and tried to understand cookies and session and how it can be used for one code with HTML

First i want to create a login page -

2) response page ,without using any DB or mysql

If users is true- saves username to cookie, and sets session variable LogggedIn to TRUE.
Displays link to "content page".

3) content page - checks session variable - if user is LoggedIn, says Hello "XXXX" where XXXX is the username from the cookie.
If not, displays link back to login page.

Diptendu
  • 2,120
  • 1
  • 15
  • 28
Amel
  • 9

1 Answers1

0

The code will help you..

<?php

session_start();

if (isset($_POST['submit'])) {
    $userName = isset($_POST['username']) ? $_POST['username'] : '';
    $password = isset($_POST['password']) ? $_POST['password'] : '';
    $_SESSION['userName'] = $userName;

    if (isset($_SESSION['userName'])) {
        echo 'logged in';
    } else {
        echo 'Check login';
    }
}
Jagadeesh
  • 734
  • 6
  • 26