So i am working on my school's webpage and i have created a very small script with javascript that i use to show and hide a group of news articles. The problem is i dont know anything about cookies and wanted to make it so that if they close the news items it sets a cookie so that the next time they come back to the page it isnt open or vice versa. could somebody please help me with this. the html code: the javascript:
I recommend jsCookie, It could simplify your handling of javascript cookies. http://codecanyon . net/item/jscookie-easy-to-use-javascript-cookie-library/308627 - (remove spaces) Now for the solution: var jsCookie = new jsCookie; //This will create a cookie that will expire in 30 days. //Add this code when user clicks to close the headline. jsCookie.create("headlineClosed","yes",[0,30,0,0]); PHP: ---------------------------------------------- //Add this code after dom is ready: if(jsCookie.read("headlineClosed")=="yes"){ //close headline }else{ //keep open } PHP: Regards