Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8746091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:08:27+00:00 2026-06-13T12:08:27+00:00

Upon successful login, I’m saving the session variable. When the user goes to different

  • 0

Upon successful login, I’m saving the session variable.

When the user goes to different pages in the app, the session is gone even though I didn’t explicitly destroy the session. How do i fix this?

Here is a page where the session appears to disappear.

<?php
include 'core/init.php';
include 'core/sendmessage.php';
$user_info = $_SESSION['user_id'];
$getUser = mysql_query("SELECT * FROM users WHERE user_id = ".$uid);

$user_info = array();

while($currentRow = mysql_fetch_array($getUser)){
    $user_info['firstname'] = $currentRow['first_name'];
    $user_info['lastname'] = $currentRow['last_name'];
    $user_info['username'] = $currentRow['username'];
}
?>

Within core/init.php I have the session start method.

<?php
session_start();
require 'database/connect.php';
require 'functions/users.php';
require 'functions/general.php';

if (logged_in() === true) { 
$user_data = user_data($_SESSION['user_id'],'first_name','last_name','username');
}

$errors = array();
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:08:28+00:00Added an answer on June 13, 2026 at 12:08 pm

    session_start() creates a session or resumes the current one based on a session identifier passed via a GET or POST request, or
    passed via a cookie. (Visit PHP: session_start)

    Add session_start() on the beginning of each page (after your <?php tag).

    In your case:

    <?php
    if(!isset($_SESSION)) session_start(); //--> ADD this line
    
    include 'core/init.php';
    include 'core/sendmessage.php';
    $user_info = $_SESSION['user_id'];
    
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a transaction page whereby upon a successful transaction, the user is
Upon user login I check their roles. If they have no roles I want
I have this html: <div id=signbtn> <a id=login-link class=btnsignin title=Login>Sign in</a> </div> Upon successful
My app is similar to facebook. I want to retain the userID/Username upon login
i am trying to refresh the page upon successful login in the Ajax script
I am working on an app whereby the user will have the login before
I'm having a login view that accepts username and password. Upon successful authentication, i'll
I am having issues accessing session information upon login. I am using Nice Auth
Upon a certain user action, I wish to add to my UIViewController another UIView
I have a login script that verifies a username/password against data in a 'user'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.