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 7889957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:13:50+00:00 2026-06-03T06:13:50+00:00

I am having a strange issue of a session variable being empty when I

  • 0

I am having a strange issue of a session variable being empty when I clear it on the same page that I attempt to echo it. Here is a quick type-up of what I am trying to do.

Take this example;

Page A:

$_SESSION['referer'] = 'abc123';
header('Location: http://www.test.com/pageb.php');
exit();

Page B:

function get_referer() {

    $referer = '';
    if (isset($_SESSION['referer'])) {
        $referer = $_SESSION['referer'];
        $_SESSION['referer'] = null;
        unset($_SESSION['referer']);
    }
    echo $referer;
}

Now when I do this on page B with the functions…

If I run it all by itself it works:

   get_referer();

When I run the echo inside the value attribute of the input (making sure to only run the function once on the page due to it being erased after being called), it didn’t echo anything when I view source the page.

<input type="hidden" name="referer" value="<?php get_referer(); ?>" />

However, funny enough, if I make the input type=”text” it works fine.

<input type="text" name="referer" value="<?php get_referer(); ?>" />

The issue only occurs on the value attribute for input type=”hidden”

  • 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-03T06:13:51+00:00Added an answer on June 3, 2026 at 6:13 am

    You’re outputting the content with

    <input type="hidden" name="referer" value="<?php get_referer(); ?>" />
    

    you’re not viewing it on the same page as you would have if you were using type="text". When using type="hidden", you’re most likely right-clicking the window and choosing View Source in your browser. The problem is that same browsers (like Chrome) refresh the page when you do so. This means, that once you load the page, the value attribute actually contains abc123, but when you attempt to see it, the page is refreshed, and therefore the session no longer exists, hence value is empty.

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

Sidebar

Related Questions

I am having a strange issue that I can't seem to resolve. Here is
Having a strange issue - we have a page that uses a query string
I am having a strange issue with some of my packages in the same
I'm having an excessively strange issue. I'm working on a project and it's being
I'm having a strange issue with RedirectToAction in MVC 3.0. Here is the code
I'm having a strange issue that I can't seem to figure out. I tried
I'm having a strange issue with my project. It was a Web Site that
I'm having a strange issue here, i have this bit of code: <?php if
I am having a strange issue with apache and ssh, that I can correlate
I'm having a strange issue that I haven't encountered before. I'm working on the

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.