PDA

View Full Version : Get client id



MACscr
01-02-07, 07:45 AM
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.

MACscr
01-02-07, 09:06 AM
just noticed that this doesnt work either:


if ($_SESSION['loggedinstatus']=="true") {
# User is Logged In - put any code you like here
}

Matt
01-02-07, 12:55 PM
For the user id, use $_SESSION['uid']. As for the logged in if statement, that will work if you use it correctly.

Matt

MACscr
01-03-07, 08:51 AM
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?

MACscr
01-03-07, 09:51 AM
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.

MACscr
01-03-07, 10:28 AM
Possible to find out if admin is logged in?

Matt
01-03-07, 11:50 AM
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.

MACscr
01-03-07, 02:43 PM
awesome, thanks!

MACscr
01-03-07, 07:03 PM
client name? =P

bedot
01-03-07, 07:12 PM
lol :D working varliable list maybe quicker :D

Matt
01-03-07, 07:12 PM
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!

MACscr
01-03-07, 08:52 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!

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