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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:37:43+00:00 2026-05-11T21:37:43+00:00

I’ve been working on a simple forum for my site. I’m adding a feature

  • 0

I’ve been working on a simple forum for my site. I’m adding a feature that will mark unread posts + forums since your last visit.

Im essentially storing a date of last access to the forum with each user account. When a user comes back to the site, a query is ran to fetch all the post_id and post_parent_forum values, which are then added to an array, that’s stored in a SESSION variable with the key being the post_id (which is unique) and the value being the forum id (which wont be unique since posts will appear in the few forums).

In the forum index, I use in_array() for each forum, to see if the forum_id is in the array, if it is, it will be marked as “unread”.

In the thread listing, I use array_key_exists() to see if the key for each thread ID is in the array, if it is, its marked as “unread”.

When a post is viewed, the item is removed from the array with the key equal to the ID of the thread.

Is this method reasonable, or am I going to run into issues if the forum becomes more popular? Im concerned about running 20 array_key_exists() checks on each forum listing. Is it reasonably fast?

On a side note…. can I work directly with the SESSION stored array, or do I have to assign its value to a regular variable, remove a key, unset the old session var, and re-set it with the updated 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-11T21:37:44+00:00Added an answer on May 11, 2026 at 9:37 pm

    php arrays are hashtables! a hash key lookup is not very expensive, so no, i don’t think you’ll run into performance problems because of this.

    in_array is a different matter (searches through the whole array), but really – it still shouldn’t be a problem. beware of premature optimization!

    can I work directly with the SESSION stored array

    yes. $_SESSION is (normally) just an array that is populated when you call session_start() by unserializing the session files content. when the script ends or session_write_close() is called, the $_SESSION array is serialize()‘d back to the file. no magic, really.

    if you should do that is another question, after all $_SESSION is a global variable (ewwww).

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

Sidebar

Ask A Question

Stats

  • Questions 161k
  • Answers 161k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The current implementation of BindingList<T> doesn't appear to support this.… May 12, 2026 at 11:46 am
  • Editorial Team
    Editorial Team added an answer As for your Customer/Purchase ostream inserters, declare the second argument… May 12, 2026 at 11:46 am
  • Editorial Team
    Editorial Team added an answer Just a guess here: are you including RequestContext in your… May 12, 2026 at 11:46 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.