Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    glz
    glz is offline
    New Coder
    Join Date
    Apr 2007
    Posts
    57
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question writing javascript session cookies, weird function behavior

    I running this code:
    Code:
    function testCookie() {
    	document.cookie = "testSessionCookie=Enabled";
    	if (getCookieValue ("testSessionCookie") == "Enabled") {
    		alert('works!');
    	} else {
    		alert('does not work!');
    	}
    }
    
    testCookie();

    It doesn't alert anything at all! what am I doing wrong?
    I am familiar with php cookies, regular cookies vs. session ones...etc..
    I am not with javascript ones..

    What I want to do is create session cookies with javascript so that they immediately be destroyed, if there is no way to make session variables with JS, then i'll settle for a way to destroy them immedietaly

    Thanks for the help

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts


  •  

    Posting Permissions

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