Ask a Question related to PHP Development, Design and Development.
-
E-Star #1
Re: Cookies... Help Please !
In article <2lg5ivcd5n5t8ao8fp2050rc65sei8uai7@4ax.com>, Fred < @>
wrote:
Does php allow this?> if($_POST["password"] == "user")
I would use strcmp.
E-Star Guest
-
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... -
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... -
php cookies
Is it possible to set php cookies to delete after a period of user inactivity & if so how? -
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... -
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... -
David Walker #2
Re: Cookies... Help Please !
> > if($_POST["password"] == "user")
Yep, should work fine.> Does php allow this?
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
-
Matthias Esken #3
Re: Cookies... Help Please !
E-Star <unix_core@linuxmail.org> schrieb:
Yes, why not?>>> if($_POST["password"] == "user")
> Does php allow this?
Matthias
Matthias Esken Guest
-
ewolfe #4
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
>
> Thanksewolfe Guest
-
Fred #5
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
>>
>> ThanksFred Guest



Reply With Quote

