Making use of CMSB session to restrict access to certain pages

3 posts by 2 authors in: Forums > CMS Builder
Last Post: October 19, 2010   (RSS)

In our CMSB powered website we have custom a custom analytics page which dynamically generates reports about each of our users sub-domains.

From what I can tell CMSB moved from cookies to sessions for CMSB logins.

To save our users having to re-enter user names and passwords etc, and more importantly to dynamically show them the correct analytics information, I would like to use the CMSB login session that is created when they login. The link to the analytics script is contained within one of the menus in CMSB.

To do this I need to find a way to retrieve which user is currently logged in.

When I know what user is logged in I would like to be able to get info from the following fields from the contacts table:

username (a standard CMSB field)
dealer_title (a custom field in the table)

I am comfortable with much of CMSB but have no experience with sessions. I have searched round and considered the membership plug-in, but I am over budget and only need a small bit of info to achieve what I need.

Any ideas?

Thanks in advance.

Paul

Re: [8bit Gamer] Making use of CMSB session to restrict access to certain pages

By Jason - October 19, 2010

Hi Paul,

When you login to CMSB, a variable called $CURRENT_USER is created. This is an array that holds all of the information for that user that is stored in the accounts table. This means that if you add a field to this table (ie dealer_title) you'll be able to access it from the $CURRENT_USER variable.
NOTE: if you're not using the website membership plugin, you can only access this variable IF they logged in through CMS Builder.

You can access these fields like this:
<?php
echo $CURRENT_USER['username'];
echo $CURRENT_USER['dealer_title'];
?>


Hope this helps. Let me know if you run into any issues.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/