TrophyNode Posted February 18, 2014 Share Posted February 18, 2014 Hello everyone! This is my first post, so sorry for asking a question right off the bat. I was wondering if I could get help with pulling information from WHMCS' cookie for my main HTML page. I am wanting to make a login field for the index page, but When they log in, I want it to display "Welcome back, {INSERTNAMEHERE}!" and then have links going to the client area, support tickets, etc. I know it is possible, Just can't figure it out. Here is an example of what it will/would look like: http://puu.sh/71lM1.png I will be using a different theme/style to display it, but that is what I am going for. 0 Quote Link to comment Share on other sites More sharing options...
SimplyDigitalHosting Posted February 19, 2014 Share Posted February 19, 2014 You have two options. Either use jQuery and an ajax call to a custom php script and keep your page static, or make the page a php page itself. Either way you will have to use a session and a db call to query the clients name from the userid in $_SESSION. This info is not stored in a cookie. The cookie only stored a reference to a session ID which is a server side data file holding the session state of that user. Regards 0 Quote Link to comment Share on other sites More sharing options...
kumcore Posted February 19, 2014 Share Posted February 19, 2014 Hello everyone! This is my first post, so sorry for asking a question right off the bat. I was wondering if I could get help with pulling information from WHMCS' cookie for my main HTML page. I am wanting to make a login field for the index page, but When they log in, I want it to display "Welcome back, {INSERTNAMEHERE}!" and then have links going to the client area, support tickets, etc. I know it is possible, Just can't figure it out. Here is an example of what it will/would look like: http://puu.sh/71lM1.png I will be using a different theme/style to display it, but that is what I am going for. The following is what I use and it seem to work fine for me... It is a php page. Oh btw, it is worth mentioning this: In case you are trying to do this across sub-domains then the following will not work... I spent days trying to figure that out and finally realized WHMCS does not support "php session" across sub-domains. Provided you have http://www.yourdomain.com/whmcs as your install path and your "other page" is located on some where like http://www.yourdomain.com/otherpage.php the following will work: <?php //use include not require... we don't want to display an ugly error message include( "whmcs/dbconnect.php" ); //secondly check the session to see if user already logged in. if ($_SESSION['uid']) { $query="SELECT * FROM tblclients WHERE id='" .$_SESSION['uid'] . "'"; /*$result = mysql_query($query) or die(mysql_error());*/ //As above we could have used the die to display an error here.. but again visitor should not see an ugly error. $result = mysql_query($query); if($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $clientsdetails['firstname']=$row['firstname']; $clientsdetails['lastname']=$row['lastname']; } //not interested in any other variables from the above table except the ones below... //$firstname = $row['firstname']; //store first name $clientfullname = $row['firstname'].' '.$row['lastname']; //store first and last name echo "<li><a class=\"iconSmallClient\" href=\"logout.php\"><strong>Logout </strong>$clientfullname</a></li>"; } else { echo "<li><a class=\"iconSmallClient\" href=\"login.php\"><strong>Client</strong> Login</a></li>"; } ?> 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.