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'];
?>
You can see User Session Pro working in various ways, and the code used to create each page, by following these links (don't forget you may have to login to see some pages):
Remember you will have to login to view these pages. Trying viewing them without logging in to see the a default restricted access warning.
More advanced examples of how you can use User Session Pro.
Advanced Examples
Video tutorials that will show you how to accomplish some very common tasks using User Session Pro