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

The Archive Base Latest Questions

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

Ok, so I want to store some user options in $_COOKIES after form submit.

  • 0

Ok, so I want to store some user options in $_COOKIES after form submit.
My code is this:

    $reason=array_values(array_filter($_POST['reasontext']));
    $str=implode('|',$reason);

    if(!isset($_COOKIE['reason'])){
         setcookie('reason',$str,time()+86400*30*12);
    }elseif(isset($_COOKIE['reason2'])){
         setcookie("reason", "", time()-3600);
         setcookie("reason",$_COOKIE['reason2'],time()+86400*30*12);
         setcookie('reason2', "", time()-3600);
    }else{
         setcookie("reason", "", time()-3600);
         setcookie('reason',$str,time()+86400*30*12);
    }

Basically, for an array of let`s say: ‘1’=>’Test1′, ‘2’=>’Test2′, ‘3’=>’Test3′

The select tool should have had 3 options different for each user, depending on what the user submited as $_POST[‘reasontext’].

Well this isn`t so, each user can clearly see what the other one has submited and stored in the cookie which should have been Personal.

What I want is that each cookie ‘reason’ to be stored on each users computer and from there to load the different user-customised options.

Any tips?

Thanks in advance for the heads up 🙂

  • 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-25T06:16:30+00:00Added an answer on May 25, 2026 at 6:16 am

    If you want cookies to be private, you should:

    1. Make your cookie consist of a unique ID and a signature to verify the ID.
    2. Mark the cookie as secure, so it can only be transmitted via HTTPS.
    3. Check the signature to validate the ID before using it.
    4. Use the ID to lookup the data in your database.
    5. Periodically reissue the ID and signing token, so it is hard to steal/forge.

    If you want data to be stored just on the user’s computer and not be transmitted to the server, then one of the various Storage interfaces would be good for that (localStorage, sessionStorage, etc.). However, you would set that in JavaScript rather than as a result of a POST, and the disadvantage to that mechanism is that the data would be specific to the browser on which it was set, whereas with the cookie solution, you could potentially restore the user’s settings when the user logs in.

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

Sidebar

Related Questions

I want to use Context.Items to store some info of a User Control like:
Is this possible? Situation is that I want to store some XML in my
I need to store some session related data for a user. This data does
I want to store some data during my site viewing. Sometime i need to
I want to store some value from SQLite database in my buffer, but the
I want to use session object in my web app.I want to store some
I want to temporary store some mapping data. The mapping is one to one.
I store some data in MySQL and want to filter out rows that match
I store some dates in my NSMutableArray, I want to retrieve them and change
I want to store null for some of the keys in HttpRuntime.Cache as I

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.