Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Member
    Join Date
    Jul 2012
    Posts
    64

    how to create cookie

    how to create cookies

  2. #2

  3. #3
    Registered User
    Join Date
    Feb 2014
    Location
    delhi
    Posts
    572
    function setCookie(cname,cvalue,exdays)
    {
    var d = new Date();
    d.setTime(d.getTime()+(exdays*24*60*60*1000));
    var expires = "expires="+d.toGMTString();
    document.cookie = cname + "=" + cvalue + "; " + expires;
    }

  4. #4
    Registered User
    Join Date
    Feb 2014
    Posts
    467
    Here are functions you can use for creating and retrieving cookies.
    var createCookie = function(name, value, days) {
    var expires;
    if (days) {
    var date = new Date();
    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
    expires = "; expires=" + date.toGMTString();
    }
    else {
    expires = "";
    }
    document.cookie = name + "=" + value + expires + "; path=/";
    }

    function getCookie(c_name) {
    if (document.cookie.length > 0) {
    c_start = document.cookie.indexOf(c_name + "=");
    if (c_start != -1) {
    c_start = c_start + c_name.length + 1;
    c_end = document.cookie.indexOf(";", c_start);
    if (c_end == -1) {
    c_end = document.cookie.length;
    }
    return unescape(document.cookie.substring(c_start, c_end));
    }
    }
    return "";
    }
    Last edited by jackthomas087; 02-24-2016 at 07:24 AM.

  5. #5
    You need to use this code as mentioned below

    function setCookie(cname,cvalue,exdays)
    {
    var d = new Date();
    d.setTime(d.getTime()+(exdays*24*60*60*1000));
    var expires = "expires="+d.toGMTString();
    document.cookie = cname + "=" + cvalue + "; " + expires;
    }

  6. #6
    Senior Member
    Join Date
    May 2013
    Posts
    198
    function getCookie(name) {
    var name = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i<ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1);
    if (c.indexOf(name) != -1) return c.substring(name.length,c.length);
    }
    return "";
    }

  7. #7
    Senior Member
    Join Date
    Nov 2013
    Posts
    347
    Cookies are created when you use your browser to visit a website that uses cookies to keep track of your movements within the site.

  8. #8
    Senior Member
    Join Date
    Jun 2014
    Location
    United Kingdom
    Posts
    128
    Yes, I agree with Olin Lamanna. You said absolutely right.

  9. #9

  10. #10
    Senior Member
    Join Date
    Nov 2014
    Posts
    113
    you need to know more about PHP function then you have to start a program on cookie.

  11. #11
    Member
    Join Date
    Dec 2014
    Posts
    54
    Cookies are bits of data that a web browser stores on your visitor's computer. They can be very useful if you need to store things like your visitor's preferences or login data or other things that are specific to a particular visitor.

  12. #12
    Senior Member
    Join Date
    Dec 2014
    Location
    Florida
    Posts
    142
    When a web server has sent a web page to a web browser, the connection is shut down, and the server does not remember everything about the user.

  13. #13
    Member
    Join Date
    Dec 2014
    Posts
    54
    A cookie, also known as an HTTP cookie, web cookie, or browser cookie, is a small piece of data sent from a website and stored in a user's web browser while the user is browsing that website.

  14. #14
    Registered User
    Join Date
    Jan 2014
    Location
    USA
    Posts
    43
    To create cookies you can use this code.

    {
    var d = new Date();
    d.setTime(d.getTime()+(exdays*24*60*60*1000));
    var expires = "expires="+d.toGMTString();
    document.cookie = cname + "=" + cvalue + "; " + expires;
    }

  15. #15
    Senior Member
    Join Date
    Dec 2014
    Location
    Florida
    Posts
    142
    A cookie, also known as an HTTP cookie, web cookie, or browser cookie, is a small piece of data sent from a website and stored in a user's web browser while the user is browsing that website. Every time the user loads the website, the browser sends the cookie back to the server to notify the website of the user's previous activity.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

  Find Web Hosting      
  Shared Web Hosting UNIX & Linux Web Hosting Windows Web Hosting Adult Web Hosting
  ASP ASP.NET Web Hosting Reseller Web Hosting VPS Web Hosting Managed Web Hosting
  Cloud Web Hosting Dedicated Server E-commerce Web Hosting Cheap Web Hosting


Premium Partners:


Visit forums.thewebhostbiz.com: to discuss the web hosting business, buy and sell websites and domain names, and discuss current web hosting tools and software.