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

  • SEARCH
  • Home
  • 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 9072985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:18:21+00:00 2026-06-16T18:18:21+00:00

I have a piece of code below where it contains $_SESSION variables: if (isset($_POST[‘id’]))

  • 0

I have a piece of code below where it contains $_SESSION variables:

if (isset($_POST['id'])) {

$_SESSION['id'] = $_POST['id'];

}

if(isset($_SESSION['sessionNum'])){
            //Declare my counter for the first time

            $_SESSION['initial_session'] = $_SESSION['sessionNum'];
            $_SESSION['sessionNumber'] = intval($_SESSION['sessionNum']);
            $_SESSION['sessionCounting'] = 1;

    }

…

ASSESSMENT: (<?php echo $assessment ?>) TOTAL ASSESSMENTS: <?php echo $_SESSION['initial_session'] ?>

The above statement displays this:

ASSESMENT: (WESSF)  TOTAL ASSESSMENTS: 2

But two pages down the line (completesession.php) I want to use couple of those $_SESSION variables. Problem though is that if I do a var_dump($_SESSION['sessionNum']) then it only int(1) but not the value 2. Yet it does output (WESSF) for var_dump($_SESSION['id']). Why is this?

Below is the completesession.php) page:

<?php

ini_set('session.gc_maxlifetime',12*60*60);
ini_set('session.gc_divisor', '1');
ini_set('session.gc_probability', '1');
ini_set('session.cookie_lifetime', '0');
require_once 'init.php'; 

error_reporting(E_ALL);
ini_set('display_errors', 1);

session_start();

  var_dump($_SESSION['id']);
  var_dump($_SESSION['sessionNum']);

?>
  • 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-16T18:18:22+00:00Added an answer on June 16, 2026 at 6:18 pm

    You might be looking in the wrong session key here. Use:

    var_dump($_SESSION);
    

    to display all sessions keys.

    Also the code you’ve posted is not counting up any number, so the number 1 looks correct (with the few I can see), and 2 would not be correct.

    A final note: Because you can successfully see int(1) it shows that the session feature in your PHP setup is actually working. So you might have just made some mistake somewhere to set the correct key/value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a piece of code below where it contains buttons and each button
I have a piece of code below where it contains buttons A-Z. Each button
I have a piece of code below where it contains 26 buttons from A-Z.
I have a piece of code (below) that can get the text of an
I have a piece of matlab code below which reads data from a table.
I have a piece of code below where it displays a message if javascript
I have a piece of code below where it echos a salted password: $pass
I have a piece of code that looks something like below and it works
Requirement : I have a piece of code similar to the code below. I
I have a piece of code something like below. I'm using Microsoft Visual C#

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.