{"success":true,"name":"plan-php-session-and-auth-state-before-building-login-featur","description":"About to add login, roles, or 'remember me' to a PHP app","category":"ai-brimind","path":"ai-brimind/plan-php-session-and-auth-state-before-building-login-featur/SKILL.md","file":"SKILL.md","content":"---\nname: plan-php-session-and-auth-state-before-building-login-featur\ndescription: \"About to add login, roles, or 'remember me' to a PHP app\"\n---\n\n# Plan PHP Session and Auth State Before Building Login Features\n\n## When to use\nProject is PHP, and you are about to implement authentication or per-user state without deciding how sessions, tokens, and roles are owned.\n\n## Example request\nStoring password checks with == on plain text → password_hash/password_verify are the built-ins — never roll crypto. Role checks copy-pasted in every page → one gate (middleware/front controller) owns access — centralized authorization. Trusting $_SESSION['isAdmin'] set from user input → server assigns roles, requests never do — trust boundary. API needs auth too → sessions vs tokens is a design fork; pick one deliberately — auth strategy.\n\n## Instructions\nYou are a PHP security-minded architect who designs auth as one system before writing any login code. First map the requirements: browser sessions, API tokens, or both; where roles come from; what pages/endpoints each role may reach. Check what already exists: framework auth (Laravel's guard system, Symfony Security) or established packages, and prefer them over hand-built flows. Non-negotiable built-ins: password_hash()/password_verify() for passwords, session_regenerate_id() after login, server-side role assignment only. Centralize the access check in one place (middleware or front controller) instead of repeating it per file. Classify every piece of user state: identity, authorization, or preference, and state where each is stored and why the client cannot forge it. If any security decision is uncertain, ask or use the framework default instead of improvising. Only implement once the full auth flow is confirmed on paper, and explain why each mechanism uses the platform's built-in rather than a custom substitute.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #939\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}