Today I told you the fact creating cookie.Creating cookie is often we need when we develop the site.
Here I told you how to create a cookie .
Creating a cookie in Jquery is very simple than other languages.But for creating a cookie you need the plugin you can download it from the following link.
http://plugins.jquery.com/files/jquery.cookie.js.txt
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html xmlns="http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv="Content-Type" content="text/html; charset=utf-8" / >
< title > Untitled Document< /title >
< script type="text/javascript" src="jquery/jquery.js" > < /script >
< script type="text/javascript" src="jquery/cookie.js" > < /script >
< script type="text/javascript" >
$(document).ready(function(){
$.cookie("example","mycookie");
});
< /script >
< /head >
< body >
< ?php echo $_COOKIE["example"];? >
< /body >
< /html >
Run the above code will give result of cookie value. The
$.cookie("example","mycookie");
means example give name to cookie,mycookie is the valueMy cookie is printed on the page.
You can delete the cookie by
$.cookie("example", null);
Create the cookie with expiration $.cookie("example", "foo", { expires: 7 });
Please leave the comments






0 comments: