Skip to main content

What is a cookie in PHP?

Entry PHP
Quick Answer Cookies store small data in the browser sent with every request to the domain. setcookie("name", "value", expiry, path, domain, secure, httponly). Accessible via $_COOKIE["name"]. Persist across browser sessions (based on expiry). Less secure than sessions (data on client). Use for: remember me functionality, user preferences, tracking. Set HttpOnly=true (prevents JS access) and Secure=true (HTTPS only).

Answer

A cookie stores small data in the user’s browser for preferences or authentication.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice