save cookie and retrieve in javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • oranoos3000
    New Member
    • Jan 2009
    • 107

    save cookie and retrieve in javascript

    hi
    i want to set cookie with javascript
    i use this code
    Code:
    <script language="javascript">
    document.cookie="username='ali'";
    
    </script>
    with using this code when i look at previous cookie that stored in my computer
    i dont this cookie
    how do save cookie and retrieve with javasript?
    thanks alot for your help
    Last edited by acoder; Jun 26 '09, 11:26 AM. Reason: Added [code] tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    To deal with cookies easily, you need three functions: to save, read and delete. Here are two links which should help:

    W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.


    PS: use the script type attribute, not the deprecated language attribute:
    Code:
    <script type="text/javascript">

    Comment

    Working...