Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

question about php setcookie

Featured Replies

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 :)

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...

  • 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

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)

  • 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 :)

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...

  • 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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.