Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session Management without Application.cfm

Status
Not open for further replies.

bhargava

MIS
May 3, 2001
26
0
0
IN
Hi,

I am developing an Application where, I am required to use Session variables to identify the user and perform user related task.

I want to achieve this by using Session Variables as they provide a much better way of handling user sessions, but I can't use Application.cfm to define application wide settings.

Is there a way out for what I want or I am talking out of my senses.

Kindly suggest

Amit
 
Hi bhargava ,

Using the application.cfm is a correct choice.

Beneth you can find an example:


<CFAPPLICATION NAMEbhargava&quot;
CLIENTMANAGEMENT=&quot;Yes&quot;
SESSIONMANAGEMENT=&quot;Yes&quot;
SETCLIENTCOOKIES=&quot;Yes&quot;
SESSIONTIMEOUT=#CreateTimeSpan(days, hours, minutes, seconds)#
APPLICATIONTIMEOUT=#CreateTimeSpan(days, hours, minutes, seconds)#
CLIENTSTORAGE=&quot;cookie&quot;>


<!--- Check if UserID (UID) is defined in a cookie --->
<cfif parameterExists(Client.UID)>
<cfset Client.UID = &quot;#UID#&quot;>
(your code here)
<cfelse>
<!--- We will generate a new random userID--->
<cfset random_word = &quot;&quot;>
<cfloop index=&quot;ii&quot; from=&quot;1&quot; to=&quot;7&quot;>
<cfset random_number = &quot;#RandRange(1,26)#&quot;>
<cfset alphabet = &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;>
<cfset random_letter = &quot;#Mid alphabet,random_number,1)#&quot;>
<cfset random_word = &quot;#ListAppend(random_word,random_letter)#&quot;>
</cfloop>
<cfset random_word = &quot;#Replace(random_word, &quot;,&quot;, &quot;&quot;, &quot;ALL&quot;)#&quot;>
<cfset random_number = &quot;#RandRange(1000,9999)#&quot;>

<cfset Client.UID = &quot;#random_word##random_number#&quot;>

</cfif>

<!--- set data source for this application --->
<CFSET dsn = &quot;my_dsn&quot;>

I hope this is of any use.
With kind regards
Bram
 
hmmm...

If I read your post correctly bhargava it looks like you're asking how to do session variables without an application.cfm file. I'm not sure why you have that restriction but without prying I can tell you that that should not be a problem, you will just have to include the code just like Bramvg showed you in each file. Probably the easiest would be putting that code in a text file and useing <CFINCLUDE... to put it in the header of each file.

Have fun...
 
thanks all,

hawkins that did the trick.

thanks a lot

Amit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top