March 29, 201016 yr Ok so i was wondering say u have a login page and u wanna have where u can remember the user but u can only set the cookie before anyother output how can i set the cookie at the top of the page before anyother output but only after i validate the form and have the remember me clicked
March 29, 201016 yr I don't like working with cookies but if I understand what you mean... I think by 'before any output' it means HTML output likes <html>, <head> and such. You should be able to set a cookie in a line of PHP right at the very top of your page just after a validation script so long as it's all before an actual HTML tag. Cookies aren't enabled in every browser...
March 29, 201016 yr Author I don't like working with cookies but if I understand what you mean... I think by 'before any output' it means HTML output likes <html>, <head> and such. You should be able to set a cookie in a line of PHP right at the very top of your page just after a validation script so long as it's all before an actual HTML tag. A good alternative to cookies is just add a column in your database for 'remember' if remember is ticked then set the field to 1 in the database and then in your usercp let the user disable this if they choose to. Cookies aren't enabled in every browser... Ok thank u good suggession i'll do that insted +1 for u
March 29, 201016 yr I'd try the first suggestion I made about putting it just before the html tags, I just realised the database solution would require some IP work (A)
March 29, 201016 yr Author I'd try the first suggestion I made about putting it just before the html tags, I just realised the database solution would require some IP work (A) Nah not really u just update the database for that user when u logout and set the value to 0 then update it again when u login and set the value to 1
March 29, 201016 yr If you only want to remember them whilst they are logged in I'd look at using sessions... definitely much easier and requires less database load...
March 29, 201016 yr Author If you only want to remember them whilst they are logged in I'd look at using sessions... definitely much easier and requires less database load... Oh yes i know that part but i was gonna remember them incase they wanted to stay logged in even if they closed the browser
Create an account or sign in to comment