Cookies... Help Please !

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Re: Cookies... Help Please !

    In article <2lg5ivcd5n5t8ao8fp2050rc65sei8uai7@4ax.com>, Fred < @>
    wrote:
    > if($_POST["password"] == "user")
    Does php allow this?

    I would use strcmp.
    E-Star Guest

  2. Similar Questions and Discussions

    1. Cookies in FMS
      In my application Flash Media Server 2 makes HTTP requests to retrieve configuration data. Page that is requestet sets some cookies. I was very...
    2. Help with cookies
      I'm having trouble accessing my cookies after they're set. If I do a response.write on the cookie value immediately after it's set in code, it...
    3. php cookies
      Is it possible to set php cookies to delete after a period of user inactivity &amp; if so how?
    4. PHP and cookies
      ok I have a question maybe this might help if you have $_COOKIE that is a session cookie in path '/' you also have a cookie $_COOKIE that is a...
    5. cookies under php 4.06
      okay, i know this is stupid, and i'm gonna kick myself when someone points out the obvious... i've just put a site online, and found the server's...
  3. #2

    Default Re: Cookies... Help Please !

    > > if($_POST["password"] == "user")
    > Does php allow this?
    Yep, should work fine.

    About the rest of it though, you may be better off with using sessions
    instead, which are like a cookie on the server, and the session ID can be
    kept by either a cookie, or just passing a string with every page, etc.
    Look up sessions in the PHP documentation.

    David


    David Walker Guest

  4. #3

    Default Re: Cookies... Help Please !

    E-Star <unix_core@linuxmail.org> schrieb:
    >> if($_POST["password"] == "user")
    >
    > Does php allow this?
    Yes, why not?

    Matthias
    Matthias Esken Guest

  5. #4

    Default Re: Cookies... Help Please !

    Fred -
    There are a couple of good articles at devshed i would suggest
    reading. On this page you will find a 3-part article dealing with
    user authentication:
    [url]www.devshed.com/Server_Side/PHP[/url]

    As far as your cookie...from php.net:
    "setcookie() defines a cookie to be sent along with the rest of the
    HTTP headers. Like other headers, cookies must be sent before any
    output from your script (this is a protocol restriction). This
    requires that you place calls to this function prior to any output,
    including <html> and <head> tags as well as any whitespace. If output
    exists prior to calling this function, setcookie() will fail and
    return FALSE. If setcookie() successfully runs, it will return TRUE.
    This does not indicate whether the user accepted the cookie."

    Personally, I setup user authentication with sessions, not with
    setcookie. Since you are using php4 or better, you might think about
    doing the same.

    hope this helps!

    erw



    Fred <Fred @ HelpPlease.com> wrote in message news:<2lg5ivcd5n5t8ao8fp2050rc65sei8uai7@4ax.com>. ..
    > Hi
    >
    > I use a form to allow my users to enter 1 of 2 passwords :
    >
    > user or admin
    >
    > They submit the form to this :
    >
    > <?php
    > if($_POST["password"] == "user") {
    > SetCookie("user","verified");
    > header("Location:local.php");
    > exit;
    > }
    >
    > elseif($_POST["password"] == "admin") {
    > SetCookie("admin","verified");
    > header("Location:admin.php");
    > exit;
    > }
    >
    > header("Location:unauthorised.html");
    > exit;
    > ?>
    >
    >
    > on each page (NOT Admin Pages) I have included :
    >
    > include ("check.php");
    >
    > check.php is:
    >
    > <?php
    > if($_COOKIE['user'] != "verified") {
    > header("Location:unauthorised.html");
    > exit;
    > }
    > ?>
    >
    > on admin pages I include :
    >
    > <?php
    > if($_COOKIE['admin'] != "verified") {
    > header("Location:unauthorised.html");
    > exit;
    > }
    > ?>
    >
    > However this does not seem to be working !!
    > Its not setting the cookie so I can't get into the pages !
    >
    > IIS5 & latest PHP, Register_Globals: OFF
    >
    > Thanks
    ewolfe Guest

  6. #5

    Default Re: Cookies... Help Please !

    Thanks !

    On 26 Jul 2003 16:51:47 -0700, [email]ericwolfe@wisewolfe.com[/email] (ewolfe) wrote:
    >Fred -
    >There are a couple of good articles at devshed i would suggest
    >reading. On this page you will find a 3-part article dealing with
    >user authentication:
    >[url]www.devshed.com/Server_Side/PHP[/url]
    >
    >As far as your cookie...from php.net:
    >"setcookie() defines a cookie to be sent along with the rest of the
    >HTTP headers. Like other headers, cookies must be sent before any
    >output from your script (this is a protocol restriction). This
    >requires that you place calls to this function prior to any output,
    >including <html> and <head> tags as well as any whitespace. If output
    >exists prior to calling this function, setcookie() will fail and
    >return FALSE. If setcookie() successfully runs, it will return TRUE.
    >This does not indicate whether the user accepted the cookie."
    >
    >Personally, I setup user authentication with sessions, not with
    >setcookie. Since you are using php4 or better, you might think about
    >doing the same.
    >
    >hope this helps!
    >
    >erw
    >
    >
    >
    >Fred <Fred @ HelpPlease.com> wrote in message news:<2lg5ivcd5n5t8ao8fp2050rc65sei8uai7@4ax.com>. ..
    >> Hi
    >>
    >> I use a form to allow my users to enter 1 of 2 passwords :
    >>
    >> user or admin
    >>
    >> They submit the form to this :
    >>
    >> <?php
    >> if($_POST["password"] == "user") {
    >> SetCookie("user","verified");
    >> header("Location:local.php");
    >> exit;
    >> }
    >>
    >> elseif($_POST["password"] == "admin") {
    >> SetCookie("admin","verified");
    >> header("Location:admin.php");
    >> exit;
    >> }
    >>
    >> header("Location:unauthorised.html");
    >> exit;
    >> ?>
    >>
    >>
    >> on each page (NOT Admin Pages) I have included :
    >>
    >> include ("check.php");
    >>
    >> check.php is:
    >>
    >> <?php
    >> if($_COOKIE['user'] != "verified") {
    >> header("Location:unauthorised.html");
    >> exit;
    >> }
    >> ?>
    >>
    >> on admin pages I include :
    >>
    >> <?php
    >> if($_COOKIE['admin'] != "verified") {
    >> header("Location:unauthorised.html");
    >> exit;
    >> }
    >> ?>
    >>
    >> However this does not seem to be working !!
    >> Its not setting the cookie so I can't get into the pages !
    >>
    >> IIS5 & latest PHP, Register_Globals: OFF
    >>
    >> Thanks
    Fred Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139