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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:14:36+00:00 2026-05-26T06:14:36+00:00

Due to server settings I am having to use $_COOKIE instead of $_SESSION to

  • 0

Due to server settings I am having to use $_COOKIE instead of $_SESSION to manage session vars for a project.

On my search form I set an initial cookie but am unclear whether this is helpful or needed?

setcookie('NOSG', 'oHai', time()+7200, '/', 'some.org');

Each time the search results page loads I iterate over the cookies and back date the ones I need to clear and then set the new values like so:

if ($board) {
  foreach ($_COOKIE as $k => $v) { 
    if (preg_match('/boa_/', $k)) {
      setcookie($k, '', time()-3600, '/', 'some.org');
    }
  }
  foreach ($people as $p) {
    setcookie('boa_'.$p->ID, $p->whatever, time()+7200, '/', 'some.org');
  }
}

Mostly this is used for making sticky selections in multi-line <SELECT> inputs.

Is this approach sound? I have rarely used $_COOKIE for anything.

// EDIT 1:12 PM GMT-06:00
All of the comments and answers are focused on fixing sessions. I assume this is because there is some reason the method suggested is NOT sound? The question asked is about using $_COOKIE to remember form settings. Would anyone care to respond as to why the method I am using is or is not appropriate to the problem?

  • 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-26T06:14:36+00:00Added an answer on May 26, 2026 at 6:14 am

    None of the respondents addressed my question: Is using $_COOKIE to store session data a sound method?

    Experience has taught me what they would not. Not all browsers handle cookies in the same way. For instance Internet Explorer has limits per domain on the number of cookies: http://support.microsoft.com/kb/941495

    So the answer is- $_SESSION is superior to cookies as it is handled by PHP in the same manner for all browsers.

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

Sidebar

Related Questions

Due to the nature of the live server I deploy to, my mail settings
We have a servlet which occupies more virtual memory on the server due to
Due to unknown reasons since a few days my Plesk server will no longer
Due to a harddrive crash, I lost my SQL server database files for a
I'm deploying to a Debian server with Capistrano which fails due to locked a
I use nexus opensource version maven 2.2.1 When I type mvn help:effective-settings, i got
I've just set our development Django site to use redis for a cache backend
If I run a 2010 visual studio C# web project using the Use Visual
Due to a number of constraints that I won't get into, I have to
Due to the lack of documentation for this on MSDN, I am forced to

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.