Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2003
    Location
    england
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question PHP Session ID Login

    Hi can anyone help me creating this script:
    1. I want to create a script what you can register to a site and it stores your details in maybe a cookie format. When you come to login it grabs the cookie and also sets a session ID. Please can anyone help me?

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    I want to create a script what you can register to a site and it stores your details in maybe a cookie format
    PHP Code:
    session_start();
    // form processed already, this is the validation page
    // form field called username

    setCookie("username",$_POST['username'],time()+36000);
    // Cookie now set with username included

    $_SESSION['username'] = $_POST['username'];

    // Session now set with username 
    Now login page
    PHP Code:
    if(isset($_COOKIE['username'])){
      
    // do query on cookie info to check the user does actually exist etc
    }elseif(isset($_SESSION['username'])){
      
    // Send straight to members area, as user is already logged in
    }else{
      
    // Send to login form



  •  

    Posting Permissions

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