Forums

PHP

This topic is locked

sessions and page restrictions.

Posted 25 Mar 2005 21:22:58
1
has voted
25 Mar 2005 21:22:58 gav ste posted:
hi, I currently have a site that allows a student to log in and view articles. this was done in dreamweaver. current page restrictions use the authentication server behaviour.

i have two tables: users > id,username,pswd,usergroup,accesslevel
articles > id, title, desc, text, date, usergroup

i can display the username at the top of all the relavent pages.

here's the problem:

each article has a feild in the database called usergroup.

i want to restrict access to the article page by usergroup.

however the students usergroup is not static like group1 or group2, they are changed and updated all the time.

i want to restrict it so when the student logs in they can only access the articles that are in their usergroup.

how do i do, restrict access to articles where session usergroup = usergroup of the article?

thanks in advance
g


Replies

Replied 26 Mar 2005 07:39:28
26 Mar 2005 07:39:28 Chris Charlton replied:
You would do this in your SQL code - either in <i>Simple</i> or <i>Advanced Recordset</i> mode. In <i>Simple</i> (default) mode, you choose the WHERE statement to use a SESSION variable (usergroup).

If you're trying to get multiple permissions, then you may want to look into MySQL's SET column type (if you're <i>are</i> using MySQL) to store multiple values in one field, and you can do the same with the usergroup column (SET) to allow multiple groups access. That may help reduce problems of students updating their usergroup frequently.

Hope that helps.

~ ~ ~ ~ ~ ~ ~
Chris Charlton <i>- DMXzone Manager</i>
<font size=1>[ Studio MX/MX2004 | PHP/ASP | SQL | XHTML/CSS | XML | Actionscript | Web Accessibility | MX Extensibility ]</font id=size1>
Replied 26 Mar 2005 15:42:27
26 Mar 2005 15:42:27 gav ste replied:
thanks for the help,

i just ned to get it right in my head, your saying:

set a session varriable called usergroup (when the user loggs in) then on the article page(which displays the article for the user of a certain group) i need to filter my record set by session variable called usergroup.

is that right?
thanks in advance
gavin

Replied 27 Mar 2005 21:03:51
27 Mar 2005 21:03:51 Chris Charlton replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>...set a session varriable called usergroup (when the user loggs in) then on the article page(which displays the article for the user of a certain group) i need to filter my record set by session variable called usergroup.

is that right?<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Yes, you can add the SESSION var to your authoring (DW), in your <i>Data Bindings</i> panel (Add Session var). Then <b>make sure you assign that SESSION var when they login, and make sure you kill the SESSION var after logout</b>.

~ ~ ~ ~ ~ ~ ~
Chris Charlton <i>- DMXzone Manager</i>
<font size=1>[ Studio MX/MX2004 | PHP/ASP | SQL | XHTML/CSS | XML | Actionscript | Web Accessibility | MX Extensibility ]</font id=size1>

Reply to this topic