Richard,

In order to have access to session variables, you need to have a line 
like this in your Application.cfm file:

<CFApplication Name="MyApp" SessionManagement="Yes" 
SessionTimeout="#CreateTimeSpan(0,2,0,0)#">

Then you'll access session variables like this:

<CFQuery Name="Verify" DataSource="MyDSN">
    SELECT *
    FROM UsersTable
    WHERE 1=1
        AND UserName = '#Form.UserName#'
        AND Password = '#Form.Password#'
</CFQuery>

<CFSet Session.LoggedIn = false> <!--- start out assuming they're going 
to fail --->
<CFIf Verify.RecordCount GT 1>
    <CFSet ErrorCode = "TooManyMatches"> <!--- this is probably 
overkill, but you never know --->
<CFElseIf Verify.RecordCount>
    <CFSet Session.LoggedIn = true> <!--- you can say "yes" if you like 
it's all boolean to CF --->
</CFIf>

In order to redirect a user you'll use the <CFLocation> tag. Like this:

<CFIf Session.LoggedIn>
    <!--- Redirect --->
    <CFLocation URL="/Path/To/MyApp.cfm" AddToken="No">
    <!--- for secruity reasons it's important to include the 
'AddToken="No"' part.
<CFElse>
    <!--- Send 'em back to login with an error code --->
    <CFLocation URL="login.cfm?errorcode="passwordmismatch" AddToken="No">
    <!--- you can of course be more cryptic with your url vars and error 
codes --->
</CFIf>

Does this help? I'm sorry if I got too basic. I mean no offense. Holler 
if you're still having trouble. :o)

Cheers,
Chris







Richard White wrote:
> hi, am just wondering if anyone can help me, i haven't had any luck with this 
> all day and i have to give a presentation tomorrow :(
>
> Also, i need to set up some session variables as soon as the user is logged 
> on, but because i cant work out how to direct the page  when they are logged 
> on, i cant find the place where i need to setup the session variables.
>
> I enter the session variables in the piece of code where i say 'if password = 
> dbpassword' then authentication = "YES". i add the session variables here but 
> they dont appear to be read. very strange
>
> would appreciate any help thanks
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:264794
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to