Cannot modify header information - headers already sent...
Moderator: General Moderators
Cannot modify header information - headers already sent...
Ok, I'm sure SOMEone has run into this problem somewhere using PHP right? I'm trying to set cookies but it keeps giving me an error of:
Cannot modify header information - headers already sent...
...for each cookie that is trying to be set. I know I can't "print" or "include" anything before the cookies are set but I need to check to check the user_name / password against the database before i set the cookies. Is there a way around this without needing server/php.ini file access?
If I could figure out how to send PHP variables in a Javascript/HTML URL that would fix my problem too. Does anyone know how to do that?
Thanks,
Jr
Cannot modify header information - headers already sent...
...for each cookie that is trying to be set. I know I can't "print" or "include" anything before the cookies are set but I need to check to check the user_name / password against the database before i set the cookies. Is there a way around this without needing server/php.ini file access?
If I could figure out how to send PHP variables in a Javascript/HTML URL that would fix my problem too. Does anyone know how to do that?
Thanks,
Jr
OK!... I have TRIED and TRIED and TRIED to figure out how to fix this problem and have gone around in circles about a million times.
- I can't send a PHP header() redirect after I check for user authentication
- I can use a JavaScript redirect but i cant send php variables in the URL with it
- and i obviously cant setcookies() in a function after authentication even though there is nothing print""ed or include""d before it in the function
- I have looked up using OutputBuffering but NONE of the tutorials make sense to where I can get that to work
- And i really dont know where to go from here!!!
Does ANYone know the "best" way to do this that isn't just a "band-aid" fix? I would GREATLY appriciate it if someone could help, this has been killing me for the longest time.
- I can't send a PHP header() redirect after I check for user authentication
- I can use a JavaScript redirect but i cant send php variables in the URL with it
- and i obviously cant setcookies() in a function after authentication even though there is nothing print""ed or include""d before it in the function
- I have looked up using OutputBuffering but NONE of the tutorials make sense to where I can get that to work
- And i really dont know where to go from here!!!
Does ANYone know the "best" way to do this that isn't just a "band-aid" fix? I would GREATLY appriciate it if someone could help, this has been killing me for the longest time.
Ok, my bad...
I didnt realize that I forgot to "print" the PHP variable when I used it in the JavaScript redirect (didn't read down that far in the tutorial). I DIDN'T however use the Output Buffering like the tutorial said. I just used a redirect paget that gets variables and then passes them back to an IF statement (at the top of the page) that actually sets the cookies.
Thanks for the help guys.
Much Appriciated,
Jr-
Thanks for the help guys.
Much Appriciated,
Jr-