work_it_work Posted January 26, 2009 Author Share Posted January 26, 2009 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/" Quote Link to comment https://forums.phpfreaks.com/topic/142035-solved-help-me-please-with-save-listing-save-search/page/2/#findComment-746744 Share on other sites More sharing options...
gevans Posted January 26, 2009 Share Posted January 26, 2009 after this line; $new_a_array = $_COOKIE['saved_announcements'].", $new_a_id"; put this; die(''.$new_a_array); Quote Link to comment https://forums.phpfreaks.com/topic/142035-solved-help-me-please-with-save-listing-save-search/page/2/#findComment-746752 Share on other sites More sharing options...
work_it_work Posted January 26, 2009 Author Share Posted January 26, 2009 same result (((((((((((( the id is replaced in cookie instead of add another after comma ( Quote Link to comment https://forums.phpfreaks.com/topic/142035-solved-help-me-please-with-save-listing-save-search/page/2/#findComment-746758 Share on other sites More sharing options...
gevans Posted January 26, 2009 Share Posted January 26, 2009 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/142035-solved-help-me-please-with-save-listing-save-search/page/2/#findComment-746760 Share on other sites More sharing options...
work_it_work Posted January 26, 2009 Author Share Posted January 26, 2009 tadaaaa : Line 1: Line 2: it wasn't set note that i add a bracket after this line setcookie("saved_announcement", $new_a_id, time()+$year); and here bracket } Quote Link to comment https://forums.phpfreaks.com/topic/142035-solved-help-me-please-with-save-listing-save-search/page/2/#findComment-746767 Share on other sites More sharing options...
work_it_work Posted January 26, 2009 Author Share Posted January 26, 2009 by the way, it's not working .... Quote Link to comment https://forums.phpfreaks.com/topic/142035-solved-help-me-please-with-save-listing-save-search/page/2/#findComment-746773 Share on other sites More sharing options...
gevans Posted January 26, 2009 Share Posted January 26, 2009 Well, it doesn't seem to be storing the cookie at all, Without deleteing your cookies run a different id through the url 4 or 5 times and see if it prints anything different than Line 1: Line 2: it wasn't set Quote Link to comment https://forums.phpfreaks.com/topic/142035-solved-help-me-please-with-save-listing-save-search/page/2/#findComment-746790 Share on other sites More sharing options...
work_it_work Posted January 26, 2009 Author Share Posted January 26, 2009 http://localhost/tataee/tatae/save_listing.php?id=1 http://localhost/tataee/tatae/save_listing.php?id=2 http://localhost/tataee/tatae/save_listing.php?id=3 http://localhost/tataee/tatae/save_listing.php?id=4 http://localhost/tataee/tatae/save_listing.php?id=5 ... http://localhost/tataee/tatae/save_listing.php?id=9 same result, it replaces the existing id in the cookie with the new one executed from url .... :'( :'( :'( Quote Link to comment https://forums.phpfreaks.com/topic/142035-solved-help-me-please-with-save-listing-save-search/page/2/#findComment-746800 Share on other sites More sharing options...
gevans Posted January 26, 2009 Share Posted January 26, 2009 I think this has something to do with setting cookies on a local server. Also a cookie requires a page reload as it is sent in the HTTP header, I think this code will work in a live environment, I can't see why it won't work.... Quote Link to comment https://forums.phpfreaks.com/topic/142035-solved-help-me-please-with-save-listing-save-search/page/2/#findComment-746803 Share on other sites More sharing options...
work_it_work Posted January 26, 2009 Author Share Posted January 26, 2009 ok, i agree with you, but cookies work perfect on my server... i use login sessions... can you test this script somewhere? Quote Link to comment https://forums.phpfreaks.com/topic/142035-solved-help-me-please-with-save-listing-save-search/page/2/#findComment-746810 Share on other sites More sharing options...
work_it_work Posted January 26, 2009 Author Share Posted January 26, 2009 ok, the file is online: http://tataee.z1.ro/save_listing.php?id=134 try it to see same thing, id replace instead of put it after a comma Quote Link to comment https://forums.phpfreaks.com/topic/142035-solved-help-me-please-with-save-listing-save-search/page/2/#findComment-746816 Share on other sites More sharing options...
premiso Posted January 26, 2009 Share Posted January 26, 2009 <?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. Quote Link to comment https://forums.phpfreaks.com/topic/142035-solved-help-me-please-with-save-listing-save-search/page/2/#findComment-746851 Share on other sites More sharing options...
work_it_work Posted January 26, 2009 Author Share Posted January 26, 2009 well i solved this, it just need an array to work. the server wasn't the problem... tank you very much for all of you that helped here!!! this topic will be marked as solved, most of the problem was solved here! Quote Link to comment https://forums.phpfreaks.com/topic/142035-solved-help-me-please-with-save-listing-save-search/page/2/#findComment-746992 Share on other sites More sharing options...
premiso Posted January 26, 2009 Share Posted January 26, 2009 You can store an array in a cookie by serialize it and then unserialize it when you retrieve to re-form the array. Quote Link to comment https://forums.phpfreaks.com/topic/142035-solved-help-me-please-with-save-listing-save-search/page/2/#findComment-747006 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.