Member Home Page after Login

A member-only page checks authenticated session state before displaying private content. Redirect unauthenticated visitors to login and escape member data before placing it in HTML.

Start the Session before Output Top ↑

session_start();

Require an Authenticated Session Top ↑

if (
    !isset(
        $_SESSION['mem_id'],
        $_SESSION['userid']
    )
) {
    header(
        'Location: mem-login.php'
    );
    exit;
}

This corrects the older malformed isset() example and makes the access rule explicit.

Escape Session Data before HTML Output Top ↑

$safeUserid = htmlspecialchars(
    (string)$_SESSION['userid'],
    ENT_QUOTES,
    'UTF-8'
);

echo 'Welcome ' . $safeUserid;

What to Store in the Session Top ↑

Keep only the server-side identity/state your application needs, such as a numeric member ID and user ID. Avoid displaying the raw session ID and avoid putting passwords, verification tokens or other secrets into the session.

See PHP session variables.

Session Expiry and Authorization Top ↑

Authentication answers “who is the user?”; authorization answers “may this user perform this action?”. Check authorization on every protected operation, not only when the user first logs in.

Logout Top ↑

Use the logout flow to clear the session when the member signs out.

Original Source Examples Retained for Migration Reference Top ↑

Historical code: these source-page examples are retained so no learner-purpose example is silently lost. Use the modern secure patterns above for new work.

Original example 1

session_start();

Original example 2

if (isset($_SESSION['userid']&& !empty($_SESSION['userid']))) {
// Welcome message 
}else {
// Ask the user to login
}

Additional Original Learning Routes Top ↑






plus2net.com






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer