Re: Setcookie()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

My problem was a headers already sent error, which I fixed by redirecting
the form POST to a seperate file instead of the same login.php. Thanks for
all your help!

2008/10/13 Stut <stuttle@xxxxxxxxx>

> On 12 Oct 2008, at 23:51, Micah Gersten wrote:
>
>> The question is, why aren't you using a session variable instead of
>> cookies?  That's one of the greatest features of PHP.
>>
>
> If you're able to use cookies instead of sessions, and the size of the data
> you're storing is fairly small, it's always better to use cookies. Sessions
> complicate scalability.
>
> Ben: The *only* restriction around use of setcookie is that there cannot be
> any *output* before it. You can have as much code as you want as long as it
> doesn't output anything. If your script outputs content before your business
> logic is done then (IMHO) it's wrong and needs to be rewritten anyway,
> regardless of the need to set a cookie.
>
> -Stut
>
> --
> http://stut.net/
>
>  Ben Stones wrote:
>>
>>> What I mean is I cannot use setcookie, I need to check if user
>>> credentials
>>> are correct first (which is BEFORE setcookie) and if so, set a cookie. I
>>> can't do that unless setcookie is first, but I need to check if the user
>>> credentials is correct. Furthermore I cannot use setcookie in the header
>>> as
>>> I want to display a message saying that they have successfully logged in
>>> in
>>> the correct area of my template.
>>>
>>> 2008/10/11 Per Jessen <per@xxxxxxxxxxxx>
>>>
>>>
>>>  Ben Stones wrote:
>>>>
>>>>
>>>>  I'm using cookies for my website script and upon users logging in a
>>>>> cookie is set. Problem for me is that the cookie doesn't work due to
>>>>> headers already sent. Is there anyway of fixing this because, there is
>>>>> no possible way of adding setcookie() to the top of the PHP file when
>>>>> the cookie is holding the username from the POSTed form.
>>>>>
>>>>>  This must be a self imposed restriction on your side, coz' otherwise I
>>>> see no problem.
>>>>
>>>>
>>>> /Per Jessen, Zürich
>>>>
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux