I need a script that will detect if a user is logged into my page (via a cookie) and if he is display a certian menu, and if he isn't display a different menu. Can Javascript read a browsers cookies, how would it look? Thanks for any help I may be lucky enough to receive
I think it would be something similar to this function ReadCookie(cookieName) { var theCookie=""+document.cookie; var ind=theCookie.indexOf(cookieName); if (ind==-1 || cookieName=="") return ""; var ind1=theCookie.indexOf(';',ind); if (ind1==-1) ind1=theCookie.length; return unescape(theCookie.substring(ind+cookieName.length+1,ind1)); }
Hi.... When u want to check for the user login status its not much preferred to go for cookies....since u are storing data on the client machine and this can be a security issue.......so y dont u try session handling......that is very very effective...and most preferred thanks and regards Prasad