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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:32:34+00:00 2026-05-26T00:32:34+00:00

I got this code: if( empty ($cache[$id]) ) { $arr[$id] = @TIMENOW; setcookie(‘id’, cArr($arr,

  • 0

I got this code:

if( empty ($cache[$id]) ) {
    $arr[$id] = @TIMENOW;
    setcookie('id', cArr($arr, 'set'), -1, @PATH);
} else {
    $cache[$id] = @TIMENOW;
    setcookie('id', cArr($cache, 'set'), -1, @PATH);
}

And it is adding only one key, to the cookie, if I’ll go to the another thread , it’ll reset the array, and won’t add more keys. I mean, if the user goes to the thread with id 1 then if( empty ($cache[1]) ) is adding 1, instead it’ll update existing value, AND if user will go now to the thread with ID 5, it will do the same, and if( empty ($cache[5]) ) is empty , then it’ll add the key with ID 5 to the array so I’ll have both keys now: 1 and 5.

Hope you got it. If you don’t , feel free to ask for whatever you wan’t, I’ll reply for all of your quesitons.

  • 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-26T00:32:35+00:00Added an answer on May 26, 2026 at 12:32 am

    It would be helpful to know what you’re doing in cArr(). But without it, this will add to your cookie for each new thread a user visits.

    //get previous values
    $id = $_GET['thread_id'];
    $cache = array_key_exists('id', $_COOKIE) ? unserialize($_COOKIE['id']) : array();
    
    //add to $cache
    $cache[$id] = TIMENOW;
    setcookie('id', serialize(cArr($cache, 'set')), -1, PATH);
    

    WARNING: But keep in mind, that with just setting a cookie, your webserver can be exploited. So better not use searialize and unserialize to store simple static values inside your cookie.

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

Sidebar

Related Questions

I've got this code: rs1 = getResults(sSQL1) rs2 = getResults(sSQL2) rs1 and rs2 and
I've got this code in a pair of button click event handlers on a
I've got this code here: SqlCommand CodeStatus = new SqlCommand(SQL, DB); DB.Open(); Reader =
How can I fetch images from a server? I've got this bit of code
I got this doubt while writing some code. Is 'bool' a basic datatype defined
I was given this code a while back. I finally got around to testing
I've got a problem with inheritance and generics. This is the code that illustrates
I got some legacy code that has this: <?PHP if(isset($_GET['pagina'])==homepage) { ?> HtmlCode1 <?php
I've got some code that looks like this: using (DBDataContext dc = new DBDataContext(ConnectionString))
I've got HTML code that roughly looks like this: <li id=someid-11> <img src=... alt=alt

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.