Jump to content

[SOLVED] help me please with save listing / save search


work_it_work

Recommended Posts

well, it still doesn't work

what i did:

erased all the cookies and everything from IE

went to temporary internet folder to see if it was empty, and it was

 

i executed the first ulr http://localhost/tataee/tatae/save_listing.php?id=3333335 cookie appear in temporary folder and had this content:

saved_announcement

3333335

localhost/tataee/tatae/

1536

312670464

30056191

2590556560

29982765

*

executed the second url: http://localhost/tataee/tatae/save_listing.php?id=555556

new cookie looks like this:

 

saved_announcement

555556

localhost/tataee/tatae/

1536

532670464

30056191

2806966560

29982765

*

 

why it's not working?

please note the cookie it's not named like a regular one ex:"cookie:admin@update.intervideo.com/" internet address is"cookie:admin@update.intervideo.com/"

it's named like this:"tatae/" and the internet address is "Cookie:admin@localhost/tataee/tatae/"

Link to comment
Share on other sites

replace all your code with the following and copy and paste what you have on screen;

 

<?php
//adding another announcement
$new_a_id = $_GET['id'];
$year = (60*60*24*365);
echo 'Line 1: '.$_COOKIE['saved_announcements'].'<br />';
if(isset($_COOKIE['saved_announcements'])){
echo 'Line 2: it was set<br />';
   $a_ids = explode(",", $_COOKIE['saved_announcements']);
   forech($a_isd as $a_id_check) {
      if($new_a_id == trim($a_id_check)) {
         header("Location: a-page-because-that-announcement-is-already-saved.php");
         exit;
      }
   }
   $new_a_array = $_COOKIE['saved_announcements'].", $new_a_id";
   echo 'Line 3: '.$new_a_array;
   setcookie("saved_announcement", $new_a_array, time()-$year);
   setcookie("saved_announcement", $new_a_array, time()+$year);
} else {
echo 'Line 2: it wasn\'t set<br />';
setcookie("saved_announcement", $new_a_id, time()+$year);
?>

Link to comment
Share on other sites

<?php
if (isset($_COOKIE['saved_announcement'])) {
$newCookie = $_COOKIE['saved_announcement'] . ", " . $_GET['id'];
setcookie('saved_announcement', $newCookie, time()+3600, "/", "yourdomain.com");
}else {
setcookie('saved_announcement', $_GET['id'], time()+3600, "/", "yourdomain.com");
}

echo "Cookie Contains: " . $_COOKIE['saved_announcement'];
die();
?>

 

Doing that outputs this after I ran that for id=1 and id=2 and id=3

 

Cookie Contains: 1, 2, 3

 

I do not know where your script is messing up, possible at the setcookie function, notice I added the path and domain to that.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.