How would YOU do this?

Results 1 to 2 of 2

Thread: How would YOU do this?

  1. #1
    Join Date
    Dec 1969

    Default How would YOU do this?

    My ASP displays a series of icons (with hyperlinks) at the footer of each page. Certain icons are displayed depending on the user&#039s permissions. <BR><BR>I am currently making a query each time to determine the users permissions and then display the corresponding icons. I KNOW this isn&#039t the best way to do it, but hey, it worked. I really want to make only one query when the user logs into the app, then store icon data in some sort of variable. It seems that this would be faster for the user.<BR><BR>How would you store an array of permissions? Session variables? Cookies?<BR><BR>Please provide some code to show how to write a few different permissions then how to pull them back out in a loop...<BR><BR>Thanks

  2. #2
    Join Date
    Dec 1969

    Default RE: How would YOU do this?

    The way I do it is this. When the user logs on I store temporary cookie on there harddrive that is gone when they shut off the browser. Ok each time the page loads I have an include file that contains a user class. The user class takes in the cookie and verifies thats who they are. It also sets all the permission properties inside the class. So on each of your pages where you include this file you have a premade class with the user and all its permissions. I dont know how effecient that is it may put a little overhead on the server to have to compile a class every time but I dunno. You could also use a dictionary object. If you dont want to use a vbscript class you could also just have the include file not use a class and set standalone varibles or use a dictionary object. The class just makes things easier to maintain.<BR><BR>using vbscript classes<BR><BR><BR>heres a basic template of what mine does...IM not writing the actual code just commenting to show you what to fill in.<BR><BR>class clsUser<BR> public access,username,password,isUser &#039permission vars<BR> public &#039&#039 put some user info vars here to fill<BR><BR> sub logon()<BR> username = request.cookies("username")<BR> password = request.cookies("password")<BR><BR> &#039&#039Test the user name and password<BR> <BR> &#039&#039if the user is logged on then call setPermissions<BR> setPermissions <BR> end sub<BR> <BR> sub setPermissions()<BR> isUser = true<BR> &#039&#039add the rest of your permission vars here.<BR> end sub <BR> <BR>end class<BR><BR>Now... just do this...<BR>set myUser = new clsUser<BR>myUser.logon<BR><BR>if (myUser.isUser) then &#039&#039Is <BR> response.write "Your a user"<BR>else <BR> response.write "Your not a user."<BR>end if

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts