Accessing User Information

From ARK
Jump to: navigation, search

The auth scripts make several pieces of information about the currect user available as session variables. Ideally you should make use of any live versions of this information rahter than pulling them fresh from the session over and over again.

The session variables

The session variables are saved by the auth script when the user logs in. The variables are:

  1. $_SESSION['user_id']
  2. $_SESSION['soft_name']
  3. $_SESSION['sgrp_arr']
  4. $_SESSION['loginIPAddress']

Bear in mind that as these are saved to the session by the authenticate.php script, this script will need to be rerun in order to force a reload of these variables, therefore any edits made to the user's profile will not be loaded intot eh session until they log out and login again.


This is the id of the user, ie the id from the table cor_tbl_people.


This is a concatenation of the firstname and lastname fields. The two fields are seperated with a space.


This is an array of the sgrps to which the user belongs.

Live variables

Where possible try to make use of the previously called live variables rather than making fresh variables and making new calls to the session. This is not a major performance worry, but it is to avoid general code untidiness that will be hard to remove in the future.

cre_by and cre_on

One of the most important uses of the current user information is the cre_by variable which is used to record who created a particular record. This var is called from the session and made live by the process script. Generally it is inadvisable to make calls to the live var as it may have been altered to fit a particular update query or it may only be set under certain conditions.

Bear in mind that this is the user's ID number.

In order to create a cre_by use the following code:

 $cre_by = $_SESSION['user_id'];