MACscr Posted January 2, 2007 Share Posted January 2, 2007 I am adding some additional pages to the client area and was wondering how i could get the user id or clientname of the currently logged in user. Any ideas? This is probably only something that Matt can answer, but i figured others might want to know as well. 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted January 2, 2007 Author Share Posted January 2, 2007 just noticed that this doesnt work either: if ($_SESSION['loggedinstatus']=="true") { # User is Logged In - put any code you like here } 0 Quote Link to comment Share on other sites More sharing options...
WHMCS CEO Matt Posted January 2, 2007 WHMCS CEO Share Posted January 2, 2007 For the user id, use $_SESSION['uid']. As for the logged in if statement, that will work if you use it correctly. Matt 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted January 3, 2007 Author Share Posted January 3, 2007 As for the logged in if statement, that will work if you use it correctly. Matt ok, then why doesnt your sample page addition code work? 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted January 3, 2007 Author Share Posted January 3, 2007 ah, my fault. It was because the page i was testing it on was not ssl and i logged in using ssl. Doh. It works. 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted January 3, 2007 Author Share Posted January 3, 2007 Possible to find out if admin is logged in? 0 Quote Link to comment Share on other sites More sharing options...
WHMCS CEO Matt Posted January 3, 2007 WHMCS CEO Share Posted January 3, 2007 ok, then why doesnt your sample page addition code work? Yes, it does - glad you got it working. Possible to find out if admin is logged in? You can use $_SESSION['adminloggedinstatus'] to see if the admin is logged in. 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted January 3, 2007 Author Share Posted January 3, 2007 awesome, thanks! 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted January 3, 2007 Author Share Posted January 3, 2007 client name? =P 0 Quote Link to comment Share on other sites More sharing options...
bedot Posted January 3, 2007 Share Posted January 3, 2007 lol working varliable list maybe quicker 0 Quote Link to comment Share on other sites More sharing options...
WHMCS CEO Matt Posted January 3, 2007 WHMCS CEO Share Posted January 3, 2007 You'll need to run a query on the Client ID if it's not availabe as a smarty variable 0 Quote Link to comment Share on other sites More sharing options...
imaginit Posted January 3, 2007 Share Posted January 3, 2007 I set up some smarty plugins to gather this info and other info, I can at least tell you how I did it... $_SESSION['uid'] is what session variable stores the currently logged in User ID and you can then use that to get almost any info about the client whenever a variable is not available, ie... if ($_SESSION['loggedinstatus']=="true") { $client_info = mysql_fetch_all("SELECT firstname, lastname, companyname FROM tblclients WHERE userid = ".$_SESSION['uid']); if (count($client_info)) { $firstname = $info[0]['firstname']; $lastname = $info[0]['lastname ']; $companyname= $info[0]['companyname']; } } If you are doing this inside the WHMCS systm, the DB connection should have already been opened by the WHMCS headers and code, so all you need to do is request the info. Hope that helps! 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted January 3, 2007 Author Share Posted January 3, 2007 I set up some smarty plugins to gather this info and other info, I can at least tell you how I did it... $_SESSION['uid'] is what session variable stores the currently logged in User ID and you can then use that to get almost any info about the client whenever a variable is not available, ie... if ($_SESSION['loggedinstatus']=="true") { $client_info = mysql_fetch_all("SELECT firstname, lastname, companyname FROM tblclients WHERE userid = ".$_SESSION['uid']); if (count($client_info)) { $firstname = $info[0]['firstname']; $lastname = $info[0]['lastname ']; $companyname= $info[0]['companyname']; } } If you are doing this inside the WHMCS systm, the DB connection should have already been opened by the WHMCS headers and code, so all you need to do is request the info. Hope that helps! Thanks, i was just double checking with matt so i didnt have to add another db hit if it wasnt needed. i like to keep them to a minimum 0 Quote Link to comment Share on other sites More sharing options...
jramicl Posted April 4 Share Posted April 4 $clientID = $_SESSION['uid']; workks fine :) 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.