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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:23:25+00:00 2026-05-23T07:23:25+00:00

Upon refreshing http://mydomain.com , it will generate a random ID to display on the

  • 0

Upon refreshing http://mydomain.com, it will generate a random ID to display on the page.

For example, http://mydomain.com generates 54 the first time, and upon reloading, 112, etc.

I’d like to save each of the randomly generated IDs to a session, so each time it reloads, I can go back to the last one. For example, the first time it saves 54 to a session, and when http://mydomain.com reloads and generates 112, I can link back to the 54.

I can’t use HTTP_REFERER or REQUEST_URI, so I tried to work on my own version, but it’s only saving it once. I can’t figure out how to update it upon viewing the next ID.

    if(empty($_SESSION['lastURL'])) {
        $_SESSION['lastURL'] = $submissionId; // $submissionId is randomly generated
            } else {
        echo $_SESSION['lastURL'];
    }

Is my current code. Where should I update the session to store the next ID?

Turns out the reason it kept misfiring was because it kept firing an additional ajax request, so I was getting a randomly generated id each time.

I (with the help of a friend) figured out by using the following code, and setting it before it randomly fires each time:

    if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest'){
    // Not an ajax request - just a normal page load
    $_SESSION['lastid'] = $_SESSION['currentid'];
    $_SESSION['currentid'] = $submissionId;
}
  • 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-05-23T07:23:26+00:00Added an answer on May 23, 2026 at 7:23 am

    You’re only setting $_SESSION['lastURL'] once because it is only empty() once. You’ll need to update this value whenever you generate a new ID (thus making it the new “old” one).

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

Sidebar

Related Questions

I'm putting together http://konrad-grabowski.com and the artworks on the front page should just float
Edit: for some reason it seems like its refreshing the page upon hitting the
Once upon a time, to write x86 assembler, for example, you would have instructions
Upon page load I want to move the cursor to a particular field. No
Upon serving a request for an ASPX page, if ASP.NET notices any change to
Upon receiving a TCP RST packet, will the host drop all the remaining data
Once upon a time, I had a 'DEV' configuration and a 'Web.DEV.config' transformation file
I have the following JQuery code that processes a GET request upon page load:
I'm taking Microsoft's walk through on MVC 2 Forms Authentication - http://msdn.microsoft.com/en-us/library/ff398049.aspx According to
Once upon a time, I dabbled in programming Homebrew for the Nintendo DS. During

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.