Jump to content

delete values from a cookie


JKG

Recommended Posts

hello,

 

i have a cookie which contains ids, like: 123,33,45,67,89,

 

i then have a little ajax script and interface where the user can delete id's.

i can post these ids, which might look like this: 45,123,

 

how can i delete the posted id's from the cookie?

 

i would just grab the cookie, then reset it with the new values, but dont know the function that would strip the id's. trim()? strSOMETHING()?

 

 

CURRENT CODE:

 

JS:

 

<script>
function close_box(id){
$('span.close').click(function() {
	$(this).parent().fadeOut(400);	
  		$.post("<?php echo $html_dir . $scripts_dir . 'ajax/contact_ids_delete.php'; ?>",{idsToDelete:id});				   
});
}
</script>

(generated) HTML

	 echo "<div class=\"info-box\">".$i++.") ".$displayEmail['business_name']."<span onclick=\"close_box('".$displayEmail['ID'].",')\" class=\"close\">x</span></div>";

 

PHP

<?php
session_start();
if(isset($_POST['idsToDelete'])){
     $_SESSION['contact_id_del'] .= $_POST['idsToDelete'];
} else {
    $contact_id_trimmed = implode(',', array_unique(explode(',', $_SESSION['contact_id_del'])));
    echo $contact_id_trimmed;
    //setcookie("contact_ids", $contacts_trimmed, time()+1000, "/", "");
}
?>

 

thanks for your help, Joe

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.