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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:47:03+00:00 2026-05-28T05:47:03+00:00

I am looking since yesterday to fix this problem, I know there are plenty

  • 0

I am looking since yesterday to fix this problem, I know there are plenty of similar tutorials but somehow they didnt work for my situation.

What I am trying to do is setting the cookie whenever the user click on any product(It should store product_id). So this product is going to be added to chart.

I check it on javascript console of the chrome but there is a strange error “Uncaught SyntaxError: Unexpected token }” and it says there isnt any stored cookie.

   echo "<div id='products'>";
    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 onclick='setCookie('ccname', '".$ftc2."', 'expiry');' href='#'>
    <img width='35px' height='25px' src='images/cart_icon.png'/>
        </a>
        </div>      
    </div></div> ";

        }
        echo "</div> ";

    ?>

And this javascript code is on the head of the page:

<script type="text/javascript" >
// JavaScript Document

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 DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
  }

function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
  }


</script>

thanks in advance

  • 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-28T05:47:04+00:00Added an answer on May 28, 2026 at 5:47 am

    The error is probably because of this function toGMTString(). If you had used script type="javascript", the toGMTString() would have worked. Since you’ve used script type="text/javascript", you do not need to convert to GMT format, browsers nowadays do it for you.

    I suggest you just remove the conversion to GMT and give a try.

    Regards

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

Sidebar

Related Questions

I'm looking since some time already for information on this topic, but I'm not
I'm looking for something open-source, similar to dynamicdrive.com, what they offer, since I'm not
I use Tortoise SVN usuallly, but I have been looking into Mercurial since it
Am looking into developing an iPhone native app using Titanium Developer Since this is
I'm looking for a RichTextBox with syntax highlighting! Sounds easy but I'm searching since
I've been looking around quite a while now for an answer but since I'm
Since yesterday I am looking for a way to save (mysql + php) dragged
Background: This is something I have been looking for since before even JSON was
I have searched this web looking for an answer, but it seems that this
Its been a while since i've needed to do this so i was looking

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.