Results 1 to 10 of 24

Thread: Day 10 - Let's Eat Cookie - Become PHP Expert in 30 days

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2009
    Location
    kerala
    Posts
    19,076

    Default PHP setcookie and delete cookie

    http://php.flashwebhost.com/sibichan...set_cookie.php

    PHP Code:
    <?php

    if (isset($_COOKIE['memberName'])) {

    echo 
    'Hi ! 'strtoupper($_COOKIE['memberName']) .', Welcome to Group.<br>(<a href=delete_cookie.php>Click here to delete cookie</a>)';

    exit;

    }
    if (isset(
    $_POST['memberName']) && strlen($_POST['memberName']) > 3) {

        
    setcookie('memberName'$_POST['memberName'], time()+3600);

        echo 
    'Cookie Set. Close the browser. Revisit this page, I will remember your name <br>(<a href=delete_cookie.php>Click here to delete cookie</a>)';

    }else {
    echo 
    '    Enter your Name    <form method="post" action="">    <input type="text" name="memberName">    <button type="submit" name="whatever">Enter Group</button>    </form>

    '
    ;

    }

  2. #2
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    Quote Originally Posted by sibichan1 View Post
    http://php.flashwebhost.com/sibichan...set_cookie.php

    PHP Code:
    <?php

    if (isset($_COOKIE['memberName'])) {

    echo 
    'Hi ! 'strtoupper($_COOKIE['memberName']) .', Welcome to Group.<br>(<a href=delete_cookie.php>Click here to delete cookie</a>)';

    exit;

    }
    if (isset(
    $_POST['memberName']) && strlen($_POST['memberName']) > 3) {

        
    setcookie('memberName'$_POST['memberName'], time()+3600);

        echo 
    'Cookie Set. Close the browser. Revisit this page, I will remember your name <br>(<a href=delete_cookie.php>Click here to delete cookie</a>)';

    }else {
    echo 
    '    Enter your Name    <form method="post" action="">    <input type="text" name="memberName">    <button type="submit" name="whatever">Enter Group</button>    </form>

    '
    ;

    }
    Good use of delete cookie.
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

Tags for this Thread

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
  •