aspsue
asked on
How can I get the session information?
hi,
I have an html page that the user logs into. I do not control the login.
Is it possible to capture the session information for this page?
What I want to do is enable the user to have access to my CF page if the user has first went through this html login page. I want to look to the session information and if it is the same as what I expect from the html page, then let the use continue. If not then direct them to the html page.
If on the CF page I could check if the user came from the html page, then I could redirect the user to the html page for login.
Which do you suggest as the best way?
How can I do this in CF?
Sue
I have an html page that the user logs into. I do not control the login.
Is it possible to capture the session information for this page?
What I want to do is enable the user to have access to my CF page if the user has first went through this html login page. I want to look to the session information and if it is the same as what I expect from the html page, then let the use continue. If not then direct them to the html page.
If on the CF page I could check if the user came from the html page, then I could redirect the user to the html page for login.
Which do you suggest as the best way?
How can I do this in CF?
Sue
Since u want to compare teh session information :
<cfif IsDefined("session.UserID" ) AND session.UserID EQ 'anandkp'>
<cflocation url="index.cfm">
<cfelse>
<cflocation url="login.htm">
</cfif>
K'Rgds
Anand
PS : make sure ur session variables are enabled using the CFADMIN
<cfif IsDefined("session.UserID"
<cflocation url="index.cfm">
<cfelse>
<cflocation url="login.htm">
</cfif>
K'Rgds
Anand
PS : make sure ur session variables are enabled using the CFADMIN
Hello there ! Actually your problem is the same to what I have answered last April.
Here is the solution !
In your first file type this code:
<CFAPPLICATION NAME="FORUM" SESSIONTIMEOUT="#CreateTim eSpan(0,0, 60,0)#" SESSIONMANAGEMENT="Yes" CLIENTMANAGEMENT="Yes" >
Then save as application.cfm.
Regarding the CreateTimeSpan function it sets when to destroy your session.
For your file in login form have this code:
<form name="form1" method="post" action="validate.cfm">
<p>username :
<input type="text" name="username">
</p>
<p>password :
<input type="password" name="password">
</p>
<p>
<input type="submit" name="Submit" value=" OK ">
</p>
</form>
Then save as login.cfm.
For your action file validate.cfm
<cfif '#form.username#' eq 'administrator' and '#form.password#' eq 'administrator'>
<cfset session.valid_account='#fo rm.usernam e#'>
<cflocation url="index.cfm">
<cfelse>
<cflocation url="login.cfm">
</cfif>
For your main page index.cfm, you should have this code.
This one will check if the session variable already exists.
<cfif not isDefined('session.valid_a ccount')>
<cflocation url="login.cfm">
</cfif>
<---- page content ----->
Try to run this code of mine. I hope this will help you.
GOODLUCK !
Entrance2002 :)
Here is the solution !
In your first file type this code:
<CFAPPLICATION NAME="FORUM" SESSIONTIMEOUT="#CreateTim
Then save as application.cfm.
Regarding the CreateTimeSpan function it sets when to destroy your session.
For your file in login form have this code:
<form name="form1" method="post" action="validate.cfm">
<p>username :
<input type="text" name="username">
</p>
<p>password :
<input type="password" name="password">
</p>
<p>
<input type="submit" name="Submit" value=" OK ">
</p>
</form>
Then save as login.cfm.
For your action file validate.cfm
<cfif '#form.username#' eq 'administrator' and '#form.password#' eq 'administrator'>
<cfset session.valid_account='#fo
<cflocation url="index.cfm">
<cfelse>
<cflocation url="login.cfm">
</cfif>
For your main page index.cfm, you should have this code.
This one will check if the session variable already exists.
<cfif not isDefined('session.valid_a
<cflocation url="login.cfm">
</cfif>
<---- page content ----->
Try to run this code of mine. I hope this will help you.
GOODLUCK !
Entrance2002 :)
If you want to have a pop message, instead of:
<cfif not isDefined('session.valid_a ccount')>
<cflocation url="login.cfm">
</cfif>
Try this one:
<cfif not isDefined('session.valid_a ccount')>
<script language='javascript'>
alert('Any message that you want to appear before redirecting the user to the login form');
document.location='login.c fm';
</script>
</cfif>
You should have this condition in every first line of any directory that you want to be validated...
Best wishes !
Entrance2002 :)
<cfif not isDefined('session.valid_a
<cflocation url="login.cfm">
</cfif>
Try this one:
<cfif not isDefined('session.valid_a
<script language='javascript'>
alert('Any message that you want to appear before redirecting the user to the login form');
document.location='login.c
</script>
</cfif>
You should have this condition in every first line of any directory that you want to be validated...
Best wishes !
Entrance2002 :)
Ok let me understand when you say you have NO CONTROL over the login. This means you CAN NOT change the login.htm page correct.
Can you explain where the login page is coming from? If it is a form posted to your cfm page then maybe but there is NO session created by the login.htm page.
Help us understand so we can help you.
Can you explain where the login page is coming from? If it is a form posted to your cfm page then maybe but there is NO session created by the login.htm page.
Help us understand so we can help you.
ASKER
nathans,
The login is handled by RACF validation. It is security on the server that I have no control over.
The login is handled by RACF validation. It is security on the server that I have no control over.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Example:
<CFAPPLICATION
NAME="MyApp"
SESSIONMANAGEMENT="yes"
SESSIONTIMEOUT="#CreateTim
APPLICATIONTIMEOUT="#Creat
<cfif Not IsDefined("session.UserID"
<cflocation url="index.cfm">
</cfif>
Hope this helps