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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:49:23+00:00 2026-06-16T15:49:23+00:00

I am new in PHP and don’t have much knowledge about cookies. It seems

  • 0

I am new in PHP and don’t have much knowledge about cookies.

It seems that I must store my data in cookies because I just need those data temporarily. I have read some article and tried some of it but I get blank result from it.

here is my code:

<?php
if (isset($_COOKIE['vaccine'])) {
setcookie('vaccine',$vaccine);
foreach ($_COOKIE[$vaccine] as $vaccine){ ?>

<div class="control-group">
<label class="control-label">
<?php echo '&nbsp'.'<a href="javascript:void(0);"  rel="tooltip"    
 title="Delete" onclick="delete_vaccination('.$vaccine->vaccination_record_id.');"><i class="icon-minus-sign"></i></a>'.'';?><?php echo $vaccine->vaccination_record_brand;?>

</label>
</div>

<?php }} ?>
  • 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-06-16T15:49:24+00:00Added an answer on June 16, 2026 at 3:49 pm

    You could (should?) use sessions for this. Cookies are not temporary, they are stored on the client’s computer. Sessions are temporary, they are alive until you destroy them.

    Furthermore, you have some errors in your PHP (not so much in the cookie handling): $_COOKIE[$vaccine] will dereference the value of $vaccine in your $_COOKIE array. As $vaccine seems to be an array, you are looking at $_COOKIE["Array"]. You will want to fix it thus:

    foreach ($_COOKIE["vaccine"] as $vaccine)
    

    Also, as you are putting an object in a cookie, you have to serialize/unserialize it, before setting or getting the cookie:

    // fetch the vaccines somewhere first
    setcookie('vaccine',serialize($vaccines));
    

    Then, lastly, why do you set the cookie, when the cookie is set? You should read it, when set.

    Complete code:

    <?php
    if (isset($_COOKIE['vaccine'])) {
       $vaccines = unserialize($_COOKIE['vaccine']);
       foreach ($vaccines as $vaccine){ ?>
    
          <div class="control-group">
          <label class="control-label">
          <?php echo '&nbsp'.'<a href="javascript:void(0);"  rel="tooltip"    
              title="Delete" onclick="delete_vaccination('.$vaccine->vaccination_record_id.');">
              <i class="icon-minus-sign"></i></a>'.'';?>
              <?php echo $vaccine->vaccination_record_brand;?>
    
          </label>
          </div>
    
    <?php }} ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to PHP programming and don't know much in detail about _SERVER.
I'm new to PHP, and don't have quite the grip on how it works.
New to PHP and MySQL, have heard amazing things about this website from Leo
I'm pretty new to PHP, I'm working in WordPress but I don't think that
I am new to php and trying to accomplish something that must be easy
I'm new to PHP and this is something that I don't know how to
I'm new to PHP, and I have stumble on the problem which I don't
I'm new to PHP, I've read a lot of tutorials about cookies and sessions
I'm new to PHP so I don't know whether this is possible. I need
I'm quite new to PHP so I don't know how to solve this error.

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.