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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:29:14+00:00 2026-05-25T03:29:14+00:00

I haven’t got any data to benchmark this, so beforehand i’d like to know.

  • 0

I haven’t got any data to benchmark this, so beforehand i’d like to know. What would you say would perform better with PHP with multiple users loading the same page?

1.100 sessions on a page each containing an array which each are unset at the end of the code 2.Multidimensional array: an array with 100 keys each containing an 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-05-25T03:29:15+00:00Added an answer on May 25, 2026 at 3:29 am

    overview

    From reading your question I get the feeling that you don’t understand what sessions are and how they work.

    Just in case, I’m going to explicitly state a few things about sessions that you may or may not know.

    • Sessions are created on a per-user basis, each user gets their own session key(s) and can access that data exclusively for the duration that the key persists.
    • Session data is stored in a file on the server’s filesystem
    • The user stores a key to access their particular session in the session cookie

    need

    Sessions are typically used to contain temporary, persistent, user-specific data. $_SESSION is an array, so you can store as many key-value pairs as you’d like with multidimensional arrays or objects.

    The idea behind a session is to store all related data in a single session. If there are two sets of data that have independent state durations, then you should use two sessions.

    Behind the scenes, a session is doing file IO, so there will be a necessary overhead in using a session.

    performance

    as $_SESSION isn’t all that different from any other array, there isn’t going to be a significant difference in code between using a single multidimensional array, and using 100 arrays. There will be a significant difference in the amount of read-write time used to open/close the sessions. If there’s no reason to have the data in separate sessions, use one session and alias the data as needed:

    $foo = $_SESSION['foo'];
    //do stuff with $foo
    $_SESSION['foo'] = $foo;
    

    Any arrays you create in global scope are automatically going to be multidimensional arrays anyway due to the $GLOBALS array (not that you should access them from there).

    tl; dr

    Don’t use more than one session unless you have multiple data sets that need to persist separate from each other.

    No premature optimization. Test instead of guess.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I haven't been able to find any real documentation on this, so I'm wondering
I haven't found any documentation on this or seen this done before, but is
Haven't found this in my search on Stackoverflow - I know I've seen a
I haven't made any thorough analysis of which implementation of PHP is the best
I haven't found any information on MSDN regarding this problem. If we create an
I have some data like this: 1 2 3 4 5 9 2 6
Haven't seen this feature anywhere else. I know that the 32nd bit is used
I haven't browsed through the spec, though I doubt any info is in there.
I haven't found this question, feel free to close if it's already up here.

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.