SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Addict einSTein's Avatar
    Join Date
    Aug 2006
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need help with session

    i need some help , i want to know more abt session and how to use it in logging with username and password i've a script that take out and check the username and password from the database how to register the "session" and how to use it .

  2. #2
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the register page code put this:

    PHP Code:
    <?php
    Session_start
    ();
    $_SESSION['username']=$username;
    ?>
    Remember session_start will go at very top of the page.

    Than in the users pages retreive it like:

    PHP Code:
    <?php
    Session_start
    ();
    $username=$_SESSION['username'];
    OR
    $_SESSION['username'];
    Now do some validation here like:
    if (isset(
    $_SESSION['username'])){
    Allow user to enter}else{ header('Location:login.php')
    }
    ?>
    In every page u want the user to allow with login use session_start();
    and their Session stored username that either he is logged in or not.

    Hope this will help.

  3. #3
    SitePoint Addict einSTein's Avatar
    Join Date
    Aug 2006
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanx man


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •