I'm stuck in Yii, with an Ajax call "bug". The problem is, that I have to search by checkboxes, which are stored in SESSION after hitting the search button.
After this, the keywords inserts into SESSION, and I want to print them in a tag-cloud. (with a cross in the corner -> delete this tag). The removal of these tags is handled by an ajax call:
$(".tags a").click(function(e) {
e.preventDefault();
var class1 = $(this).attr("class");
var id = $(this).attr("id");
$("#checkbox__"+id).removeAttr("checked");
jQuery.ajax({
url: "recipe/removeFromSession",
type: "POST",
data: "id=" + class1+"&rcp="+id,
dataType: "json",
"success": function(data){
location.reload();
},
"error": function(xhr, status, error) {
var err = xhr.responseText;
alert(xhr.status);
},
"cache" : false,
});
});
It calls the removeFromSession action:
public function actionRemoveFromSession() {
$remove = intval($_POST['id']);
unset($_SESSION['searchItems']['category'][$remove]);
unset($_SESSION['recipeSearch']['category'][$_POST['rcp']]);
echo json_encode($_SESSION);
}
The problem is that it doesn't unsets the value. It's still in the session. Any idea? (sorry for grammar mistakes)
Thanks
You can try this:
Set your session:
Yii::app()->session['searchItems']['category'][$keyword] = "Any string";
To unset session:
unset(Yii::app()->session['searchItems']['category'][$remove]);