473,795 Members | 3,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Global.asa and Session_OnEnd

Dear All;
I wrote this code in the global.asa but it dosen't work inspite that
it works in any asp file and also in the global.asa file but only in
the session_onstart part.This code is to delete a txt file at the end
of the session.The file was created during the user's session and has
the name of the session id. The session variable "session("mpath ")" is
the varible which will hold the path of the created file. This is my
first question also I want to know how to set the session.timeout and
where to place it in the code?
<SCRIPT LANGUAGE=VBScri pt RUNAT=Server>
sub session_onstart
session("id")=0
session("mpath" )=""

end sub

sub session_onend
set fsoglob=server. createobject("s cripting.filesy stemobject")
cpath=session(" mpath")
set Cfolder=fsoglob .getfolder(cpat h)

for each file in Cfolder.files

if instr(1,file.na me,session.sess ionid&".txt",1) then
fsoglob.deletef ile(file)
end if
next
fsoglob.close
set fsoglob=nothing

end sub
</script>

Thank You
Jul 19 '05 #1
1 2486
"Soha El-Saeed" <se*******@gawa b.com> wrote in message
news:69******** *************** ***@posting.goo gle.com...
Dear All;
I wrote this code in the global.asa but it dosen't work inspite that
it works in any asp file and also in the global.asa file but only in
the session_onstart part.This code is to delete a txt file at the end
of the session.The file was created during the user's session and has
the name of the session id. The session variable "session("mpath ")" is
the varible which will hold the path of the created file. This is my
first question also I want to know how to set the session.timeout and
where to place it in the code?
<SCRIPT LANGUAGE=VBScri pt RUNAT=Server>
sub session_onstart
session("id")=0
session("mpath" )=""

end sub

sub session_onend
set fsoglob=server. createobject("s cripting.filesy stemobject")
cpath=session(" mpath")
set Cfolder=fsoglob .getfolder(cpat h)

for each file in Cfolder.files

if instr(1,file.na me,session.sess ionid&".txt",1) then
fsoglob.deletef ile(file)
end if
next
fsoglob.close
set fsoglob=nothing

end sub
</script>

Thank You


Session_onend is not reliable (http://www.aspfaq.com/show.asp?id=2078).
Plus, you are referring to session vars which don't exist by that time.

Instead, I would run a process on user login that deletes files which are
older than a specified amount.

You can place the session.timeout command in the Session_OnStart event.

--
John Blessing

http://www.LbeHelpdesk.com - Help Desk software priced to suit all
businesses
http://www.free-helpdesk.com - Completely free help desk software !
http://www.lbetoolbox.com - Remove Duplicates from MS Outlook
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
9520
by: MostlyH2O | last post by:
Hi Folks, I'm having a hard time getting my Session_OnEnd event to fire in my global.asa. Here's what I have: <SCRIPT LANGUAGE=VBSCRIPT RUNAT=Server> SUB Session_OnStart Session.TimeOut = 30 END SUB
11
2203
by: Julian | last post by:
Hi I have code in my login.asp which sets the online field in user database to true or 1. I am trying to use the same code in global.asa to change back the online field to 0 but it doesn't work. The code is very simple and it should work, any idea why it doesn't? Sub Session_OnEnd If Session("User_ID")<>" " Then ' check if user has logged in before.
2
3347
by: Amit D.Shinde | last post by:
Hello Experts.. I need some help regarding cookies and session objects and also global.asa file I am creating one cookie when a user logs in on my website. The cookie stores the login name of the user. I want that cookie should get deleted when user closes the browser without signing out. I think it is done in global.asa file . But i don;t know how to do it?
6
1898
by: Olivier SOW | last post by:
Hi, I have this code in the global.asa file: Sub Session_OnEnd() Set oFso= CreateObject("Scripting.FileSystemObject") Set oFileTxt= oFso.OpenTextFile("c:\debugS.txt", 8, true) oFileTxt.WriteLine Now()&" SESSION END "&session.sessionId Set oFso= nothing: Set oFileTxt= nothing
28
4893
by: Prabhat | last post by:
Hello, I have the below requirement. When ever my website is opened by any link: say clicked from the google search result or a link from other website: Then I should able to know the referrer URL. How Do I get that? I know about Request.ServerVariables("HTTP_REFERER"). So I used this in
5
3945
by: WJ | last post by:
I am attempting to use the Global.Asax to store my user's configuration. Here is the concept: 1. User logs on into the site using Form Authentication. 2. I capture the user Credential, verify it and then assign this Logon ID (user) a so called User's serverside cookie. 3. My system is configured to accept 1,024 concurrent users, this means that my Global.Asax will host no more than 1,024 Logon IDs and their associated cookies/variables....
2
1262
by: cylix2000 | last post by:
I have to write Global.asa with session_onEnd. Firstly, If my IIS have a number of application, may I have a number of global.asa on each application folder? or, i can just have a global.asa on the wwwroot? Besides, I found that it seems doesn't run when I put global.asa on the application folder. How does global.asa run actually?
1
2263
by: u0107 | last post by:
Hello, I am developing a website with an MS-Access backend database. One of the tables in the database is tblUser. On accessing my website, a user is required to provide a valid user id and a password. Once a user id and password is provided, it is validated against appropriate fields in tblUser and a "logged in" flag (another field in tblUser) is set to "True". I want to set the flag to "False" at the end of the session. Session...
8
5779
by: Victor | last post by:
Can I get the events in GLOBAL.ASAX to fire if a classic ASP page is being accessed by the user?
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.