Here is the exact code you want.  You should put it in the Application.cfm insted of 
the index.cfm so it gets run regardless of what page the user starts out on (they 
might have a hyperlink to another page).

<cflock scope="SESSION" type="readonly" timeout="10">
    <!--- copy to Request scope whether or not the user is logged in, as defined by 
the existence of a session variable. --->
    <cfset REQUEST.isLoggedIn = IsDefined(SESSION.isLoggedIn)>
</cflock>

<cfif NOT REQUEST.isLoggedIn>
    <!--- if the user has not logged in (ie, this code has not been run before) run 
the code --->
    [insert custom tag call here]
    <cflock scope="SESSION" type="exclusive" timeout="10">
        <cfset SESSION.isLoggedIn = 1>
    </clock>
</cfif>

Now, when the page runs again, the session variable "isLoggedIn" will prevent the code 
from running everytime.

If you're not clear on the concept of session scope or the application.cfm, please let 
us know.  It makes all the difference for understanding how this might work.

Sharon DiOrio
----- Original Message ----- 
From: "phumes1" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Wednesday, March 20, 2002 8:53 AM
Subject: RE: Running code just one time


> At 07:31 AM 3/20/2002 -0800, you wrote:
> >Then what you need to do is set this value - <cfset auth =
> >"#CGI.AUTH_USER#"> to a session variable.
> >
> >Then on your index.cfm, just check for that session var and if it has
> >anything in it.. if it does do not run the tag, if there is not any value
> >then run the tag and populate the session var..
> >
> >Make sense?
> 
> No. It's not the cgi.auth_user I want to check. I think I'm really messing
> this up...
> 
> All I want to do is run a piece of code when the user accesses the web site
> (index.cfm) for the first time
> after username/password authentication. When the index.cfm is run anytime
> afterwards the code is ignored.
> 
> 
> 
> >HTH
> >Clint
> >
> >-----Original Message-----
> >From: phumes1 [mailto:[EMAIL PROTECTED]]
> >Sent: Wednesday, March 20, 2002 4:56 AM
> >To: CF-Talk
> >Subject: RE: Running code just one time
> >
> >
> >I just thought by saying I want to output some text I could explain it
> >better.
> >
> >I have a custom tag that goes into the NT security and outputs the groups
> >associated with the user which I'm setting
> >in my application.cfm as...
> >
> >
> >I use this variable on everypage to display the username logged in.
> >
> >The thing is when the index.cfm file is loaded again and again I *don't*
> >want the custom tag to execute. Eventually I want to grab all the
> >information from the custom tag and dump it to a database but only ONCE per
> >session.
> >
> >I hope this is clearer...:-) :-)
> >
> >
> >
> >
> >At 07:27 AM 3/20/2002 -0500, you wrote:
> > >Expire the session varibale when the user logs out..if you have them log
> > >out.
> > >Im not clear on what you are trying to do here.. what is it that you are
> > >outputting on the first page visit?
> > >
> > >
> > >-----Original Message-----
> > >From: phumes1 [mailto:[EMAIL PROTECTED]]
> > >Sent: Wednesday, March 20, 2002 7:35 AM
> > >To: CF-Talk
> > >Subject: RE: Running code just one time
> > >
> > >
> > >OK...but won't this session variable always be "1" when the application.cfm
> > >is loaded again?
> > >Do I have to set the variable to "2" once I output what I want for the
> > >first time.
> > >
> > >I'm missing something here...
> > >
> > >At 07:02 AM 3/20/2002 -0500, you wrote:
> > > >When they get logged in, set a flag in application.cfm, such as a
> > > >session session.beenHereBefore = 1, then in your index page check the
> > > >value of the variable and output accordingly.
> > > >
> > > >HTH,
> > > >Mike
> > > >
> > > >-----Original Message-----
> > > >From: phumes1 [mailto:[EMAIL PROTECTED]]
> > > >Sent: Wednesday, March 20, 2002 7:07 AM
> > > >To: CF-Talk
> > > >Subject: Re: Running code just one time
> > > >
> > > >
> > > >Hi,
> > > >
> > > >This is regarding a post from yesterday. Maybe I didn't explain it
> > > >properly. I had mentioned a custom tag but for now lets just forget
> > > >about it.
> > > >
> > > >I am running IIS on NT 4. All users have accounts on the system.  In
> > > >IIS under the "Default Web Site Properties" I went into the "Directory
> > > >Security" tab and disabled the "Anonymous Access" and enabled the "NT
> > > >Windows Challenge/Response" only.
> > > >
> > > >Now when users try to access the web page they are prompted with a
> > > >username/password Windows authentication dialog.
> > > >
> > > >If the correct username/password are entered the user is redirected to
> > > >my index.cfm file.
> > > >
> > > >This is what I would like to do.
> > > >
> > > >Within my index.cfm or application.cfm file I want to check if this is
> > > >the first time that the index.cfm file is loaded. If so, do something
> > > >otherwise do nothing.
> > > >
> > > >Below is just an example...
> > > >
> > > >
> > > >index.cfm or application.cfm
> > > >--------------------------------------
> > > >
> > > >- Check to see if this is the first time index.cfm file is loaded (at
> > > >login
> > > >time)
> > > >
> > > >     - If so dump some test
> > > >          <p>Logged in</p>
> > > >
> > > >
> > > >        If index.cfm is loaded any other time do nothing
> > > >
> > > >
> > > >I'm not sure how to incorporate this?
> > > >
> > > >
> > > >
> > > >+----------------------------------------------------------------------
> > > >+-----
> > > >--------+
> > > >
> > > >Philip Humeniuk
> > > >[EMAIL PROTECTED]
> > > >[EMAIL PROTECTED]
> > > >+----------------------------------------------------------------------
> > > >+-----
> > > >---------+
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
> 
______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to