Code Examples (for more advanced coders)

Below are examples of code you might use to accomplish some more advanced tasks using User Session Pro.

 

Retrive user created values:

Any value stored for a user can be retrieved and used in your scripts by just invoking the "returnUserValue" function. In this example the username is retrived and then echoed out to say hello to the user.

<?php
$userName = $userSessionPro->returnUserValue('username');
echo "Hello " . $userName;
?>
 

Retrive multiple user created values:

Multiple user values can be retrieved at once by using the "returnUserValues" function. Just supply it with an array of values to return. In this example the username and favourite_color are returned and echoed out.

<?php
$valueNames = array('username','favourite_color');
$userValues = $userSessionPro->returnUserValues($valueNames);
echo $userValues['username'] . "'s favourite colour is " . $userValues['favourite_color'];
?>
 

Get a different users values

Sometimes it may be appropriate to get the values of a user who is not logged in. This is accomplised by using the "returnOtherUsersValues" function and specifying the other usersID as well as the values required. In this example the username and favourite_color of userID 4 are returned and shown to the current user.

<?php
$userID = 4;//another user's id
$valueNames = array('username','favourite_color');
$userValues = $userSessionPro->returnOthersUserValues($userID,$valueNames);
echo $userValues['username'] . "'s favourite colour is " . $userValues['favourite_color'];
?>
 

Still have questions about User Session Pro?

Do you have any queries, comments or suggestions you would like us to address?
(If you would like us to get back to you please include your email address.)
Subject:
 
 
ProPHPScripts