www.webdeveloper.com
Results 1 to 3 of 3

Thread: How to set cookies for Remember Me

  1. #1
    Join Date
    Jul 2009
    Posts
    5

    How to set cookies for Remember Me

    How to set cookies for Remember Me

    if I log in to a page, with user name and password,
    I want to set cookies so that it can take itself previously entered user name and password, or I select or enter the user name it should take password itself.

    Thanks

  2. #2
    Join Date
    Nov 2008
    Posts
    2,477

  3. #3
    Join Date
    May 2009
    Posts
    14
    Quote Originally Posted by Sanjay Sirohee View Post
    How to set cookies for Remember Me

    if I log in to a page, with user name and password,
    I want to set cookies so that it can take itself previously entered user name and password, or I select or enter the user name it should take password itself.

    Thanks
    Use something like this:
    PHP Code:
    /* verify username and password first and set a flag ($verified). */

    if($verified)
    {
    setcookie("username"$_POST["username"], time() + 3600 24 365);
    }
    else
    {
    setcookie("username"$_POST["username"], time() - 1); // delete any saved cookies called "username"

    And to retrieve that cookie
    PHP Code:
    if(isset($_COOKIE["username"]))
    {
    echo 
    "Hey " $_COOKIE["username"] . "! I remember you."


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles