|
|
|
> If the setcookie has to be the first thing sent how can i run some code
> before setting a cookie?
>
> I have a bunch of if() before i set the cookie and i get the usual oops
> about the header being sent.
>
>I was having this same problem, just a few if() statements etc.. but kept
>getting the error. Turned I had some Empty lines or spaces in my code,
>after I removed these empty lines, all was fine.
Well, blank space is ok, but it depends on where it is. For example..
----------- start file1.php3 -----------
<?php
SetCookie("TestCookie", "abc");
echo "hi!";
?>
----------- end file1.php3 -----------
and..
----------- start file2.php3 -----------
<?php
SetCookie("TestCookie", "abc");
echo "hi!";
?>
----------- end file2.php3 -----------
Which one will work and which will die?? file2.php3 will work and
file1.php3 will die. This is because in file1.php3, the whitespace is
before the <?php tag. If you want to set a cookie, you cannot have any (or
at least a \n) whitespace before the first opening php tag. The second
works fine because the <?php tag is the very first thing. The whitespace
in that is not sent to the browser, and therefore the script works fine.
|
|
| PHP4 MYSQL Authentication Script with cookie. Short & Sweet
Categories : Authentication, Apache, Cookies, PHP, MySQL | | | A very simple PHP single password cookie based login without usernames. Categories : PHP, Cookies, Security, Beginner Guides | | | Authentication script to authenticate users in Active Directory through LDAP. Categories : LDAP, Authentication, Cookies, PHP | | | cookie Categories : Cookies, PHP | | | Example voting script. Lets people enter suggestions and vote for existing ones. Categories : MySQL, PHP, Cookies, Complete Programs, Databases | | | The Best Authorize Categories : PHP, MySQL, Cookies | | | Function that allows a Javascript cookie to be set after HTML has been outputted to the page.
Categories : PHP, Java Script, Cookies, HTML and PHP | | | Simple Cookie example Categories : PHP, Beginner Guides, Cookies | | | Secure Login Categories : PHP, MySQL, Cookies, Security | | | With this class you can use cookies with chips Categories : PHP, Cookies | | | Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP, PHP, HTML, PDF, Excel | | | How to make sure a that $foo is from a cookie and not from the URI. Categories : PHP, Variables, Global Variables, Cookies | | | Function that does language negotiation based on the Accept-Language header, a cookie or host name Categories : HTTP, PHP, Cookies | | | Cross Browser Session Starter Categories : PHP, Sessions, Cookies | | | Store, retrieve and delete cookies using JavaScript. Categories : Java Script, Cookies, Beginner Guides, Cookies | |
|
|
|