Skip to main content

What is a session in PHP?

Entry PHP
Quick Answer Session stores data on the server between requests. session_start() initializes it. Data stored in $_SESSION["key"] = value. Session ID sent to client via cookie (PHPSESSID). On next request, client sends the ID and PHP loads the session data. Sessions expire on browser close (or timeout). More secure than cookies (data on server). Store user ID in session, not sensitive data like passwords.

Answer

Sessions store user-specific data on the server and persist across requests.
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