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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:13:48+00:00 2026-06-06T02:13:48+00:00

I encountered an issue while I was revising my session library today, and this

  • 0

I encountered an issue while I was revising my session library today, and this might be the first time I’ve ever seen a browser-specific problem on a back end script. I hope somebody can shed some light.

Basically how the session library works is: when instantiated, it checks for a cookie called ‘id’ (in the form of a uniqid result) on the client machine. If a cookie is found, the script checks that and a hashed copy of the user agent string against entries in a session table. If a matching entry is found, the script resumes the session. If no cookie named ‘id’ is found, or if no matching entry exists in the sessions table, the script creates both. Fairly standard, I think.

Now here’s the weird part: in Firefox, everything works as predicted. The user gets one session, which he’ll always resume upon connection, as long as 24 hours of inactivity has not elapsed. But when I visit the page in Chrome, even though it looks the same and appears to be executing queries in the same order, I see two entries in the session table. The sessions share an agent string, but the ids are different, and timestamp logs indicate that the ghost session is being created shortly (within a second) after the one created for the user.

For debugging purposes, I’ve been printing queries to the screen as they’re executed, and this is an example of what I’m seeing when Chrome should be opening one session and is somehow opening two instead:

// Attempting to resume a session
SELECT id FROM sessions WHERE id = '4fd24a5cd8df12.62439982' AND agent = '9bcd5c6aac911f8bcd938a9563bc4eca'

// No result, so it creates a new one
INSERT INTO sessions (id, agent, start, last) VALUES ('4fd24ef0347f26.72354606', '9bcd5c6aac911f8bcd938a9563bc4eca', '1339182832', '1339182832')

// Clear old sessions
DELETE FROM sessions WHERE last < 1339096432

And here’s what I’m seeing in the database afterward:

id, agent, start, last
4fd24ef0347f26.72354606, 9bcd5c6aac911f8bcd938a9563bc4eca, 1339182832, 1339182832
4fd24ef0857f94.72251285, 9bcd5c6aac911f8bcd938a9563bc4eca, 1339182833, 1339182833

Am I missing something obvious? The only thing I can think of is that Chrome might be creating a hidden session in the background, possibly to crawl the page. If that’s the case though, it could become a problem later, when I begin associating active sessions with entries in the users table. I’ve been looking for possible bugs in my script, but I haven’t found anything so far, and everything works as expected in Firefox.

  • 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-06T02:13:50+00:00Added an answer on June 6, 2026 at 2:13 am

    I have run into this before and was equally confused. Since a few months ago Chrome has prefetching enabled. So to speed up perceived speed to users, it crawls most links on the page and retrieves and renders them partially in advance. Great for end users since if you’re on broadband it can really reduce page change times.

    Unfortunately for us web developers, it leads to confusion like the above. This happens for example when a Chrome user visits a website and has not yet been assigned a cookie or session, but the browser has pre-fetched multiple pages and been assigned multiple sessions.

    So let’s say someone visits a page with links to different areas of your PHP script, and the script is designed to assign a cookie to all visitors…if Chrome fetches two of those pages simultaneously or close to it, PHP will end up assigning different sessions because another thread in Chrome will basically require a new session/cookie before the other assignment has been completed.

    There are two solutions I’m aware of: One is Google’s JavaScript API for handling prerendering, which I haven’t found to be particularly good. The other way is to perform more stringent checking when handing out sessions and cookies from PHP. Either don’t assign sessions to guest users, or add some additional checks (IP, hostname, whatever).

    Hope that helps.

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

Sidebar

Related Questions

I've encountered this issue while trying to port my C++ source code from HP-UX
I've encountered this issue before while trying to install PHP5 on multiple versions of
I encountered this issue while working with the Java Collections API. Basically this is
While getting our WCF Data Service ready for production we encountered an issue with
I've encountered this issue on two different machines and can't figure out what the
I am seeking to use ViewPager 's getCurrentItem() method I've encountered this issue before
I encountered this while trying to understand ELF (Executable and Linking Format). Steps I
I've encountered a weird issue while using Reflection. So I have a domain class
I encountered a strange issue while coding a .dll file in C with gcc
I'm working on a DB/web based frontend, and have encountered an issue. First off,

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.