Forums
This topic is locked
Restrict acces to page by session var
Posted 24 Nov 2001 05:42:27
1
has voted
24 Nov 2001 05:42:27 Michael Davis posted:
I'm using the ImpAkt extension, and I'm trying to restrict access to a page depending on the value of a session variable.
I have the value being read from the database on login, it's a yes/no field. I want to only allow acces to the page if Pub = "Y".
Any Ideas?
Replies
Replied 24 Nov 2001 15:09:32
24 Nov 2001 15:09:32 Tim Green replied:
Try:-
<?php
if ($HTTP_SESSION_VARS["SessionVariableName"] != "Yes" {
header("Location: invalidlogin.php"
}
?>
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
<?php
if ($HTTP_SESSION_VARS["SessionVariableName"] != "Yes" {
header("Location: invalidlogin.php"
}
?>
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 25 Nov 2001 06:08:30
25 Nov 2001 06:08:30 Michael Davis replied:
Thanks for the response, and that seems as though it's just what I need, but I still have a question. I'm using Impakt, and can't figure out how to define a database query result as a session variable. To use your example above, I can't figure out how to define "SessionVariableName" as data from the database. Everything works fine if I hard code the value in.
Please HELP!!!
Please HELP!!!
Replied 26 Nov 2001 08:53:55
26 Nov 2001 08:53:55 Tim Green replied:
OK, I understand you dilemma.
You are part way there if you can hard code a value to the session variable. The way to set a session variable with the value of a recordset column is only one more step. You will need to do something like this :-
<?php
if (!session_is_registered("SessionVariableName") {
session_register("SessionVariableName"
}
$SessionVariableName = $RecordsetName->Fields("ColumnName"
?>
Hope this helps <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
You are part way there if you can hard code a value to the session variable. The way to set a session variable with the value of a recordset column is only one more step. You will need to do something like this :-
<?php
if (!session_is_registered("SessionVariableName") {
session_register("SessionVariableName"
}
$SessionVariableName = $RecordsetName->Fields("ColumnName"
?>
Hope this helps <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 26 Nov 2001 23:04:51
26 Nov 2001 23:04:51 Michael Davis replied:
That did the trick! Once again you have come to my rescue. Thanks again, Tim!!
Replied 27 Nov 2001 00:59:49
27 Nov 2001 00:59:49 Tim Green replied:
Always a pleasure <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>