Week 012 — The Sign-In Handoff
Getting a visitor from "I want to subscribe" to "I am subscribed" turns out to have more steps than it looks like from the outside.
Week of December 23, 2024
Progress
Worked on the subscribe button behavior for logged-out visitors. The logic: if the user is logged in, route them to the subscription page as normal (checking if they already have one, routing them to Stripe to manage it if so). If not logged in, send them to sign-in first — and when they return, pick up where they left off. That last part is the complicated piece: the sign-in page needs to know where to send the user after authentication, which means setting a session variable that the sign-in handler can read and act on.
The Hard Part
The PHP variable scoping problem appeared again, in the third distinct context. The previous occurrences: the $log variable in week three, and the product list globals last week. This time it surfaced in products.php, where a database connection variable defined at the file level wasn't visible inside a function. The fix — using PHP constants instead of variables for shared globals — had already been established as the pattern. Applied it again here.
There's something worth noting: the same fundamental misunderstanding keeps showing up in new places. PHP's default local scope for function variables is genuinely different from most other languages. Each time it surfaces, it's in a context where the fix is fast. But the pattern suggests the mental model hasn't fully settled yet.
Next Week
The sign-in handoff flow is in progress. Once the session-based redirect is working, the new user path — land, learn what srchParty is, subscribe, and start adding items — will be complete.
