homepage Welcome to WebmasterWorld Guest from 54.167.11.16
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
JS userName script query
need link to reload page and clear cookie
antipodes




msg:1490807
 5:45 am on Mar 16, 2003 (gmt 0)

Hello all,

I am building a kids (no profit) site and though I am presently learning JS in a tech college here in ozland, I am not able to write or modify a cookie username script which would be a real treat for my site surfers.

I am looking for something like the macomedia username which stores the details, but also writesIn "if this is not +user+ click here. I assume this reloads the page and clears the cookie at the same time. This is precisely where I am having the problem. I have a username script without that extra bit. Can anyone suggest where I can find this script?

thanks again
antipodes

 

korkus2000




msg:1490808
 12:49 am on Mar 21, 2003 (gmt 0)

This should work. Change NameOfCookie to the name of the cookie with the name.

<script>
function getCookie(NameOfCookie)
{
if(document.cookie.length > 0)
{
begin = document.cookie.indexOf(NameOfCookie+"=");
if(begin!= -1)
{
begin += NameOfCookie.length + 1;
end = document.cookie.indexOf(";",begin);
if(end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(begin,end));
}
}
return null;
}
function delCookie(NameOfCookie)
{
if(getCookie(NameOfCookie)){
document.cookie = NameOfCookie +"=" +
";expires= Thu, 01-Jan-70 00:00:01 GMT";
}
}

</script>

Document.write("If you are not " + getCookie() + " then <a href='javascript:delCookie()'>click here</a>");

My js cookie ablities are quite rusty. You can find the original tutorial I changed here:
[scriptbreaker.com...]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved