Results 1 to 2 of 2

Thread: cookie get value function not working.

  1. #1
    Join Date
    Aug 2011
    Posts
    27
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default cookie get value function not working.

    Hi, im trying to pull the email value from a cookie, then split the email into 2 parts to use as value for input box.. but its not working out.
    here is my code:
    Code:
    <script type="text/javascript">
    function getCookie(mailaddress)
    {
    var i,x,y,ARRcookies=document.cookie.split(";");
    for (i=0;i<ARRcookies.length;i++)
      {
      x=ARRcookies.substr(0,ARRcookies.indexOf("="));
      y=ARRcookies.substr(ARRcookies.indexOf("=")+1);
      x=x.replace(/^\s+|\s+$/g,"");
      if (x==mailaddress)
        {
     var thisemail=y;
        }
         var email_split=thisemail.split("@");
        var email_name=email_split[0];
        var email_domain=email_split[1];
      }
    }
    </script>
    
    <input size="20" class="text" name="_username"  type="text" value="<myCookie: var email_name />" readonly>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The way that's set up makes no sense to me. The function function getCookie(function getCookie(mailaddress)) takes as a parameter function getCookie(mailaddress).

    If you already know the mailaddress, why are you checking to see if it's in a cookie?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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