I have developed a New Website in HTML. Its a Multi Location or Country Website. For the same I have created the Welcome Page where it will show the list of countries available and I need to place a Remember me Check box so that next time the same computer visit my website it will not have to choose its country and will be directed to the country which it had chosen earlier.

Please tell me How can I place a cookie there. Really I don't have any Idea about cookies nor I know how to create them.

Please help me.

You place this in index.html

<script type="text/javascript" language="JavaScript">
function cookie1(){
  var sadrzaj = document.cookie;
  var ime = 'kukac';
  var pocetak = sadrzaj.indexOf(ime);
  if(pocetak!=-1)
  {
    var kraj= sadrzaj.indexOf(";", pocetak);
    if(kraj==-1){kraj=sadrzaj.length}
    pocetak += ime.length + 1;
    var vrijednost = sadrzaj.substring(pocetak, kraj);
    alert("Cookie procitan: " + vrijednost);
   }
   else{
        var dani = 7;
        var datum = new Date();
        datum.setTime(datum.getTime()+(dani*24*60*60*1000));
        var istjecanje; 
        istjecanje=datum.toGMTString();
        var ispis;
        ispis = ime +" = " + ime +  "; expires=" + istjecanje + "; path=/" ;
        document.cookie = ispis;
        alert( "Cookie kreiran: \n" + ispis);
    }
}
</script>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.