View Full Version : Get client id
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.
just noticed that this doesnt work either:
if ($_SESSION['loggedinstatus']=="true") {
# User is Logged In - put any code you like here
}
For the user id, use $_SESSION['uid']. As for the logged in if statement, that will work if you use it correctly.
Matt
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?
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.
Possible to find out if admin is logged in?
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.
lol :D working varliable list maybe quicker :D
You'll need to run a query on the Client ID if it's not availabe as a smarty variable
imaginit
01-03-07, 08:34 PM
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!
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
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.