If user logged in?

Discussion in 'JavaScript' started by praetorian guardian, Oct 30, 2007.

  1. #1
    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 :cool:
     
    praetorian guardian, Oct 30, 2007 IP
  2. praetorian guardian

    praetorian guardian Guest

    Messages:
    270
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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));
    }
     
    praetorian guardian, Oct 30, 2007 IP
  3. prasadkrn

    prasadkrn Member

    Messages:
    85
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #3
    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
     
    prasadkrn, Oct 31, 2007 IP