473,385 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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=VBScript RUNAT=Server>
sub session_onstart
session("id")=0
session("mpath")=""

end sub

sub session_onend
set fsoglob=server.createobject("scripting.filesystemo bject")
cpath=session("mpath")
set Cfolder=fsoglob.getfolder(cpath)

for each file in Cfolder.files

if instr(1,file.name,session.sessionid&".txt",1) then
fsoglob.deletefile(file)
end if
next
fsoglob.close
set fsoglob=nothing

end sub
</script>

Thank You
Jul 19 '05 #1
1 2449
"Soha El-Saeed" <se*******@gawab.com> wrote in message
news:69**************************@posting.google.c om...
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=VBScript RUNAT=Server>
sub session_onstart
session("id")=0
session("mpath")=""

end sub

sub session_onend
set fsoglob=server.createobject("scripting.filesystemo bject")
cpath=session("mpath")
set Cfolder=fsoglob.getfolder(cpath)

for each file in Cfolder.files

if instr(1,file.name,session.sessionid&".txt",1) then
fsoglob.deletefile(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
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 =...
11
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....
2
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...
6
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)...
28
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...
5
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...
2
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...
1
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...
8
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?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.