1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Get username or userid after login in javascript

Discussion in 'Google API' started by moshfeu, Sep 4, 2011.

  1. #1
    Hey. I want to get username or userid after the user login to my website via google account or the user loggedin already.
    I want to tcke the userid and get list of his Picasa's albums by his userid.
    How can I do this with javascript?
    Thanks!
    SEMrush
     
    moshfeu, Sep 4, 2011 IP
    SEMrush
  2. ramandeep kaur

    ramandeep kaur Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <html>
    <head>
    <title>login</title>

    <script type="text/javascript">

    function validate(){

    var userName = document.getElementById('username').value;
    var password = document.getElementById('password').value;
    var minLength = 6;



    if (userName == '') {
    alert("You must enter a username.");
    return false;
    }

    if (password.length < 6) {
    alert("You must enter a password of atleast 6 characters.");
    return false;
    }

    document.cookie="welcomeuser="+userName;
    return true;
    }
    </script>

    <script language="JavaScript">
    function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
    }a

    function Set_Cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
    ( (expires) ? ";expires=" + expires.toGMTString() : "") +
    ( (path) ? ";path=" + path : "") +
    ( (domain) ? ";domain=" + domain : "") +
    ( (secure) ? ";secure" : "");
    }

    var today = new Date();
    var expires = new Date(today.getTime() + (56 * 86400000));
    function set() {
    if (document.logonForm.elements[1].checked)
    Set_Cookie("userid",document.logonForm.userid.value,expires);
    if (document.logonForm.elements[3].checked)
    Set_Cookie("password",document.logonForm.password.value,expires);
    }

    function get() {
    userid = Get_Cookie("userid")
    if (userid != null) {
    document.logonForm.userid.value = userid;
    document.logonForm.elements[1].checked = true;
    }

    password = Get_Cookie("password")
    if (password != null) {
    document.logonForm.password.value = password;
    document.logonForm.elements[3].checked = true;
    }
    }
    </script>



    </head>
    <body onLoad="get()">

    <br><br><br></br><br></br></br></br>
    <table>
    <table width="500" border="2" align="center">
    <tr>
    <td style="background-color:pURPLE;">



    <h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Login Form</h1>
    <form method="post" action="menu.html" onSubmit="return validate();">
    <form name="logonform" onSubmit="return get();">

    <p> <font size="5" face="arial" color="red"> Username&nbsp;:&nbsp;<input type="text" name="Username" size="10" > </font> </p>
    <p> <font size="5" face="arial" color="red"> Password&nbsp;:&nbsp;&nbsp;<input type="password" name="Password" maxlength=7 > <BR></br>remember me<input type="checkbox"></font>


    <p><input type=submit value="Submit"/>
    <input type="reset" value="Reset Form"/></p>
    </p>
    </form>

    </td>
    </tr>
    </center>
    </table>

    <body background="11.jpg">
    <p>
    </p>
    </script>
    </body>
    </html>
     
    ramandeep kaur, Feb 6, 2012 IP
  3. moshfeu

    moshfeu Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I want to use google accout, not regular cookie, but Thanks
     
    moshfeu, Feb 6, 2012 IP