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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:35:43+00:00 2026-05-28T03:35:43+00:00

Edit: I solved it somehow with PHP. Its so specific but I want to

  • 0

Edit:
I solved it somehow with PHP. Its so specific but I want to share it in case somebody needs it. First of all I didnt give any specific name as product_id for the cookie but I just give the variable of the product_id “$ftc2” which is clicked, shown as below

onclick=\"SetCookie('".$ftc2."', '".$ftc2."', 'expiry'); 

So whenever user clicks on any product, a new cookie is created with the name of the product_id like name=2 or name=32 whatever.

then I have created a foreach on the chart page as below

<?php foreach($_COOKIE as $cookies) { echo $cookies; } ?> 

It displayes now all stored cookie values(in my case product ids) and now I can manipulate it as I want and display all products which is added to chart Maybe it is so easy and so common but somehow I couldnt find it out since morning = )) I hope it saves someone’s hours

THE QUESTION WAS:


I am building an onlineshop and What I want to do is displaying all clicked products in showChart page.(a very simple page which shows you the products that you added to your chart by clicking on chart_icon). I have tried some several common methods but I couldnt manage to do it somehow. My last desperate try was creating this addToChart() function.

Since setting the cookie part works good I simplified the code and paste just the important parts (in my opinion). Any kind of help or suggestions would be appreciated. I dont expect anyone to write the code for me.

thanks in advance

    for($i=0;$i<$num;$i++)
        {
            $ftc = mysql_result($result, $i, "product_image");
            $ftc2 = mysql_result($result, $i, "product_id");
            $ftc3 = mysql_result($result, $i, "product_name");
            $ftc4 = mysql_result($result, $i, "product_preis");
            $ftc5 = mysql_result($result, $i, "product_old_preis");
            echo "<a href='details.php?product=".$ftc2."'><div class='products_list'>
            <img width='217px' height='323px' src='".$ftc."'/>
            <div class='alt_yazi2'><b>".$ftc3 ." &nbsp;&nbsp;&nbsp;&nbsp <font      

style='float:right;'>".$ftc4."TL &nbsp;&nbsp<b style='text-decoration:line-through; float:right;'>".$ftc5."TL </b></font></b></a>
    </br>
    <div id='sepet'><a id='cookie' onclick=\"SetCookie('"cookie_product"', '".$ftc2."', 'expiry');\" href='#'>
    <img width='35px' height='25px' src='images/cart_icon.png'/>

JAVASCRIPT CODE BEGINS HERE

var today = new Date();
var expiry = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);

    function getCookieVal (offset) {
      var endstr = document.cookie.indexOf (";", offset);
      if (endstr == -1) { endstr = document.cookie.length; }
      return unescape(document.cookie.substring(offset, endstr));
      }

    function GetCookie (name) {
      var arg = name + "=";
      var alen = arg.length;
      var clen = document.cookie.length;
      var i = 0;
      while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) {
          return getCookieVal (j);
          }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
        }
      return null;
      }

    function SetCookie (name,value,expires,path,domain,secure) {

      document.cookie = name + "=" + escape (value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");

      }

    document.getElementById(cookie).onclick = function addToChart()
            {
                var cookieValue = document.getElementById(cookie).value;
                var cookiearray = new Array();
                cookiearray = cookieValue.split(",");
                return cookiearray;

            }
  • 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-28T03:35:44+00:00Added an answer on May 28, 2026 at 3:35 am

    Ok I have solved my problem with PHP. Its so specific but I want to share it in case somebody needs it.

    First of all I didnt give any specific name as product_id for the cookie but I just give the variable of the product_id “$ftc2” which is clicked, shown as below

    onclick=\"SetCookie('".$ftc2."', '".$ftc2."', 'expiry');
    

    So whenever user clicks on any product, a new cookie is created with the name of the product_id like name=2 or name=32 whatever.

    then I have created a foreach on the chart page as below

    <?php 
    foreach($_COOKIE as $cookies)
         {
                 echo $cookies;
          }
    
    ?>
    

    It displayes now all stored cookie values(in my case product ids) and now I can manipulate it as I want and display all products which is added to chart

    Maybe it is so easy and so common but somehow I couldnt find it out since morning = ))

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

Sidebar

Related Questions

EDIT: This problem has been solved. See below. Hey all. I'm building an iPhone
Edit : Solved, there was a trigger with a loop on the table (read
Edit: Solved. Hi, I'm starting with Qt, I try to connect a slot to
edit #2: Question solved halfways. Look below As a follow-up question, does anyone know
Edit: I have solved this by myself. See my answer below I have set
UPDATE: Solved. Thanks BusyMark! EDIT: This is revised based on the answer below from
I'm trying to learn a little bit more about recursion but somehow I can't
I want to change the way the edit text view looks like... I have
EDIT: solved. ans var needed to be set to 0 in every iteration.That was
EDIT: SOLVED--SOURCE CODE HERE: http://matthewdowney20.blogspot.com/2011/09/source-code-for-roku-remote-hack.html thanks in advance for reading and possibly answering this.

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.