Buffalo Posted December 12, 2015 Share Posted December 12, 2015 Hello, Did anyone try get user account name who authenticated on web? Theres an example on wiki, but all I get is "undefined" instead of name. Is this even possible? <* local accName = getAccountName(user) if not accName then return end httpSetResponseCookie("userName",accName) *> <!DOCTYPE html> <html> <body onLoad="getAcc();"> Your Account Name is: <span id="accnam"></span> <script> //getCookie function from w3schools.com function getCookie(c_name){ var i,x,y,ARRcookies=document.cookie.split(";"); for (i=0;i<ARRcookies.length;i++){ x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); x=x.replace(/^\s+|\s+$/g,""); if (x==c_name) return unescape(y); } } function getAcc(){ var acc = document.getElementById("accnam"); var name = getCookie("userName"); if(!name || name!="") acc.innerHTML = name; else acc.innerHTML = "Could not get your account name!"; } </script> </body> </html> Solved! <* httpWrite( "<script> var userName = '"..getAccountName(user).."';</script>" ) *> Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now