Skip to main content
March 11, 2011
Question

Login with different user level

  • March 11, 2011
  • 2 replies
  • 537 views

Hey guys,

I am new to Coldfusion so please forgive me for any silly questions.

I am making website where users will have different level of rights. There are pages that I want only Admin to view, there are pages that I want only Admin and Supplier to see and there are pages that every user can see.

My logic for this was I will have user_leve field in database (ie. 0 for normal user, 1 for supplier and 2 for Admin). On every page I will include little Authentication page (simple condition, allow if user_level is > 0 allow to view page, so supplier and Admin can view the page)

Now here is the issue, When user login successfully I want to set some variable values in application.cfm (like user name and user_level) so I can use them later on for authentication.

Big Question:

  1. How to set value in Application.cfm when user login?
  1. How to retrieve it when authentication?
Sorry, about the long message. Thanks for reading and your helps in advance.

    This topic has been closed for replies.

    2 replies

    12Robots
    Participating Frequently
    March 11, 2011

    I guess I should ask. Is there a reason you are using Application.cfm instead of Applicaiton.cfc?  Is this new development? Personally, I would not use App.cfm for a new project, and, if I could, I would change an App that did use App.cfm to one that uses App.cfc.

    Do you have restrictions?

    March 11, 2011

    12Robots,

    Thanks for your reply. With help of your first post I have manage to make it work. However, I have used <cfset session.loggedin = 1> every time user login and set it back to '0'  every time user log out. I hope doing it this wat will not be a huge issue!! thanks for that link, it was all I wanted.

    Also on .CFC vs .CFM

    The only time before this I have ever touched ColdFusion is when it was version 4.5 and back in those days it was only Application.cfm so I will have a look at what this CFC is and if you have any article differing these two please let me know.

    Thanks again for your kind help,

    Amit.

    12Robots
    Participating Frequently
    March 11, 2011

    You want to set up session management and store to and retreive from the SESSION scope.

    This post might help.

    http://www.learn-coldfusion-tutorial.com/SessionApplication.cfm