Question

Global.asa

Asked by: lukegriffiths110

I want to include a global.asa file that reset the sesion to "" if the user does not click on the logout button. I have been told that this can be achieved by a global.asa file. Before i start showing the code can i have some input.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2006-04-05 at 09:07:52ID21802739
Tags

logout

Topic

Active Server Pages (ASP)

Participating Experts
1
Points
500
Comments
43

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Global.asa
    Trying to learn ASP with help of a book. The Global.asa file is my question. In order to use the BrowserCap function I need to have it set for use. If I put it as an object in the Global.asa file, I am assuming I can use the {If Browser supports whatever then do whatever ...
  2. global.asa question
    Can I have one global.asa for each application on my webserver? I've been told that you can only use one global.asa for all apps...I'd like to have one for each app. Thanks!

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: kevp75Posted on 2006-04-05 at 09:21:47ID: 16383254

you can do this with a global.asa file

you would use something similar to this

Sub Session_OnEnd
   session("sessionname") = ""
End Sub

now..there is a problem to this.   Problem is, if the user closes the window, goes to another page, or their computer freezes on them, session("sessionname") will not get set to "" unless the session timeout occurs.

Best bet is to use some kind of javascript to detect if the user has clicked the X, or hit ALT-F4, then use some autoclosing popup to set session("sessionname") = ""

Or.....you could lower you session timeout in your server.  Problem is with this is what if you have a user logged in to the site longer than your timeout.....

Personally, I wold nix the whole session variable idea, and just use cookies.  if you set no expiry on the cookie, it is only valid until that user closes the browser.  If security is an issue, set the cookie using some kind of encryption, and where you need to get the value from the cookie, decrypt it.

To set a cookie use:response.cookies("cookiename") = value
to get a cookie use:variable = request.cookies("cookiename")

HTAH

 

by: kevp75Posted on 2006-04-05 at 09:22:18ID: 16383258

here's a good point of reference for ya:
http://www.w3schools.com/asp/asp_cookies.asp

 

by: lukegriffiths110Posted on 2006-04-05 at 09:35:50ID: 16383435

I also have another question it relates to the one you answered before. If I restart the server and type in the url to search.asp, as the session = "" it redirects to login. If the user then logs in correctly and then clicks the logout link which runs this code:-

<%
Session.Abandon()
Session.Contents.RemoveAll()
response.redirect("adminlogin.asp")
%>

The user shouldn't then be able to view search.asp without logging in as i have printed the session to the screen in login and it is blank. However this isn't the case as the server some how is remembering the session and search can be viewed. Why is this and can this be prevented.

 

by: kevp75Posted on 2006-04-05 at 10:41:33ID: 16384195

Session.Abandon()
Session.Contents.RemoveAll()

kills all session variables.  Only thing I can think of is a cookie.  Can you post the code for adminlogin.asp?

 

by: lukegriffiths110Posted on 2006-04-05 at 10:47:52ID: 16384285

Using the code below stops the cache another EE expert got it.

Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1

However back to the global.asa file, i am finding it hard to sort . Basically all i need is for the session to be blanked if the user doesn't logout. The code below contains the functions i need but also extra coud you pull out the functions i need or explain each line.


<SCRIPT LANGUAGE=VBScript RUNAT=Server>


Sub Application_OnStart

Application("visits")
Application("Active") = 0


'      The connection string to the mdb.
Application("connString") = "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\Inetpub\wwwroot\online_Users\Online.mdb;Uid=Admin;Pwd=pass;"

End Sub



Sub Application_OnEnd
End Sub
Sub Session_OnStart


      
Session.Timeout = 20
Session("Start") = Now
Application.Lock
Application("visits") = Application("visits") + 1
intTotal_visitors = Application("visits")
Application.Unlock

Session("VisitorID") = intTotal_visitors
Application.Lock
Application("Active") = Application("Active") + 1
Application.Unlock
End Sub


Sub Session_OnEnd



set conn = Server.CreateObject ("ADODB.Connection")
      conn.Open Application("connString")
      
Dim update__MMColParam
update__MMColParam = "1"
if (Session("MM_Username") <> "") then update__MMColParam = Session("MM_Username")
      

      ' Update the record when the user logout and write the logout time
      ' plus it sets the user as OFFLINE.
      query = "UPDATE tblActiveusers SET LoggedOut=  now() , Online=1 "
      query = query & "WHERE Online=0 AND  Username= '" + Replace(update__MMColParam, "'", "''") + "'"
      
      conn.Execute (query)
      conn.Close
      set conn = Nothing


Application.Lock
Application("Active") = Application("Active") - 1
Application.Unlock

End Sub
</script>

 

by: kevp75Posted on 2006-04-05 at 10:52:18ID: 16384342

right in here:Sub Session_OnEnd



set conn = Server.CreateObject ("ADODB.Connection")
     conn.Open Application("connString")
     
Dim update__MMColParam
update__MMColParam = "1"
if (Session("MM_Username") <> "") then update__MMColParam = Session("MM_Username")
     

     ' Update the record when the user logout and write the logout time
     ' plus it sets the user as OFFLINE.
     query = "UPDATE tblActiveusers SET LoggedOut=  now() , Online=1 "
     query = query & "WHERE Online=0 AND  Username= '" + Replace(update__MMColParam, "'", "''") + "'"
     
     conn.Execute (query)
     conn.Close
     set conn = Nothing


Application.Lock
Application("Active") = Application("Active") - 1
Application.Unlock

End Sub

you can put session("sessionname") = "", however, please keep in mind what I posted earlier about what happens if a user just goes to another page, or their computer crashes, etc...

 

by: lukegriffiths110Posted on 2006-04-05 at 10:56:58ID: 16384395

Why does the script need to be conn to the database could this be removed, i have coppied this script from the net.

 

by: kevp75Posted on 2006-04-05 at 11:01:18ID: 16384430

in the Session_OnEnd.  Looks like it is there to update a table with the logged out time of the user.  It's your call to remove it or not, just keep in mind your application may be expecting a use for this, like some kind of report, or list of logged out users and the times they logged out at.

in the Application_OnStart section, the conn is set there so it can be readily available for all web applications on the server.  While this is not the route I would do it, it is not a bad idea.

 

by: lukegriffiths110Posted on 2006-04-05 at 11:05:28ID: 16384471

Would this work appart from the crashing.

<SCRIPT LANGUAGE=VBScript RUNAT=Server>

Sub Session_OnStart
Session.Timeout = 20
Session("Start") = Now
Application.Lock
Application("visits") = Application("visits") + 1
intTotal_visitors = Application("visits")
Application.Unlock

Session("VisitorID") = intTotal_visitors
Application.Lock
Application("Active") = Application("Active") + 1
Application.Unlock
End Sub

session("sessionname") = "",

</script>

 

by: kevp75Posted on 2006-04-05 at 11:19:28ID: 16384635

It would work, however, without:Application("connString") = "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\Inetpub\wwwroot\online_Users\Online.mdb;Uid=Admin;Pwd=pass;"
 in it you will have to go through every one of your files, and make sure to update every instance of Application("connString"), otherwise the whole application will fail.

Also:  You would need to do this

Sub Session_OnEnd
     session("sessionname") = ""
     Application.Lock
     Application("Active") = Application("Active") - 1
     Application.Unlock
End Sub

in order for that to work correctly, otherwise like it is is making session("sessionname") = "" all the time, which would is pointless to do, plus the Application("Active") would not be an accurate count with out it

 

by: lukegriffiths110Posted on 2006-04-05 at 11:56:26ID: 16385037

In search the code is now:-

<!--#include file="global.asa"-->



<%
'Check if user is logged in

Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1



if Session("username") = "" then
     'If not, go to login page
     Response.Redirect("adminlogin.asp?error=2")
else
%>
<html>
<Head>
<link href="css/css.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--

div.test {
     width: 500px;
     height:300px;
     margin-bottom: 0px;
     margin-left: 10px;
     margin-right: 10px;

}
#auto {
     overflow: auto;
}

td {padding: 0px;}
-->
</STYLE>
</head>

<body bgcolor="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<body scroll="no" border="no" style="border-style: groove; border-width: 0">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><table width="856" height="428" border="1" align="center" cellpadding="0" cellspacing="" bordercolor="#ffffff">
        <tr bordercolor="#FFFFFF">
          <td height="64" colspan="5" align="left" valign="top" bordercolor="#990000" bgcolor="#990000"><img src="images/CFLogo.jpg" width="330" height="50">
            <div align="center"></div></td>
          <td width="31" rowspan="2" valign="bottom" bordercolor="#990000" bgcolor="#990000">&nbsp;</td>
        </tr>
        <tr bordercolor="#FFFFFF">
          <td width="349" align="center" valign="middle" bordercolor="#990000" bgcolor="#990000"><img src="images/admin.jpg" width="250" height="188">
          </td>
          <td height="300" colspan="4" align="center" valign="top" bordercolor="#FFFFFF" bgcolor="#000000">
            <div align="center">
              <h1><%Response.Write(Session("username"))%></h1>
            </div><DIV CLASS="test" ID="auto">


<FORM id=FORM1 name=FORM1 action="list.asp" method=post>
<P>
  <TABLE cellSpacing=0 cellPadding=0 align=center bgColor=#000000 border=0>
    <TR align="center">
      <TD width="80"><font size=1 color=#ffffff>User Name</font></TD>
      <TD width="80"><FONT size=1 color=#ffffff>Logged in</FONT></TD>
      <TD width="80"><FONT size=1 color=#ffffff>IP Address</FONT></TD>
      <TD width="80"><FONT size=1 color=#ffffff>Sort</FONT></TD>
      <TD colspan="2">&nbsp;</TD>
    </TR>
    <TR align="center">
      <TD> <INPUT style="WIDTH: 60px" width="60" id=text1 name=text1></TD>
      <TD> <INPUT style="WIDTH: 60px" width="60" id=text2 name=text2></TD>
      <TD> <INPUT style="WIDTH: 60px" width="60" id=text4 name=text4></TD>
      <TD> <SELECT id=select1 name=Combo1>
          <OPTION value=>User Name</OPTION>
          <OPTION value=>Logged in</OPTION>
          <OPTION value=>IP</OPTION>
        </SELECT> </TD>
      <TD width="80"> <INPUT style="WIDTH: 60px; color:#ffffff; BACKGROUND-COLOR: #990000" type=submit value=Search width="60" name=button></TD>
      <TD width="80"> <INPUT style="WIDTH: 60px; color:#ffffff; BACKGROUND-COLOR: #990000" type=reset value=Clear width="60" name=button></TD>
    </TR>
  </TABLE>
  </P>
</FORM>



</tr>
        <tr bordercolor="#FFFFFF">
          <td height="20" colspan="6" align="right" bordercolor="#990000" bgcolor="#990000">
            <div align="right"><font color="#FFFFFF"><a href="logout.asp">Logout</a></font></div></td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>
<%
end if
%>


In global.asa. the code is:-

<SCRIPT LANGUAGE=VBScript RUNAT=Server>

Sub Session_OnStart      
      Session.Timeout = 1
      Session("Start") = Now
      Application.Lock
      Application("visits") = Application("visits") + 1
      intTotal_visitors = Application("visits")
      Application.Unlock
      Session("VisitorID") = intTotal_visitors
      Application.Lock
      Application("Active") = Application("Active") + 1
      Application.Unlock
End Sub


Sub Session_OnEnd
      session("sessionname") = ""
      Application.Lock
      Application("Active") = Application("Active") - 1
      Application.Unlock
End Sub


the error is:-

Script error detected at line 26.
Source line: <%
Description: Expected statement

 

by: kevp75Posted on 2006-04-05 at 12:02:40ID: 16385104

you don't need to include global.asa in any file.

remove that line (<!--#include file="global.asa"-->) and see if the error comes up again

global.asa is a global file to the application.  as soon as someone requests a page on your site, global.asa executes, then the your page executes.

 

by: lukegriffiths110Posted on 2006-04-05 at 12:04:39ID: 16385129

The session is not being set back to "" what could be the problem

 

by: lukegriffiths110Posted on 2006-04-05 at 12:05:59ID: 16385144

Couldn't the code just be: -

Sub Session_OnStart    
     Session.Timeout = 1
     Session("Start") = Now
End Sub

Sub Session_OnEnd
     session("sessionname") = ""
End Sub

for what i need it to do

 

by: kevp75Posted on 2006-04-05 at 12:07:19ID: 16385156

you will have to change session("sessionname") = "" to the session variable you wish to clear.

also:
Accepted Answer from kevp75
Date: 04/05/2006 09:21AM PDT
Grade: A
 Accepted Answer  


you can do this with a global.asa file

you would use something similar to this

Sub Session_OnEnd
   session("sessionname") = ""
End Sub

now..there is a problem to this.   Problem is, if the user closes the window, goes to another page, or their computer freezes on them, session("sessionname") will not get set to "" unless the session timeout occurs.

Best bet is to use some kind of javascript to detect if the user has clicked the X, or hit ALT-F4, then use some autoclosing popup to set session("sessionname") = ""

Or.....you could lower you session timeout in your server.  Problem is with this is what if you have a user logged in to the site longer than your timeout.....

Personally, I wold nix the whole session variable idea, and just use cookies.  if you set no expiry on the cookie, it is only valid until that user closes the browser.  If security is an issue, set the cookie using some kind of encryption, and where you need to get the value from the cookie, decrypt it.

To set a cookie use:response.cookies("cookiename") = value
to get a cookie use:variable = request.cookies("cookiename")

HTAH

 

by: lukegriffiths110Posted on 2006-04-05 at 12:11:09ID: 16385211

I have changed session name to user name but still nothing how do i know iif the global.asa file is running

 

by: lukegriffiths110Posted on 2006-04-05 at 12:12:14ID: 16385222

sorry but also could this code be used in the header instead of a global.asa. file

 

by: kevp75Posted on 2006-04-05 at 12:12:59ID: 16385231

it could luke, but you also have to realize that you will need to make some serious changes to the application.

If I'm not mistaken you are building something to track your users?
in which case all that other stuff would have to stay, as it is what is going to be keeping count for you of who is logged in or out, and when they logged out and/or in.

Also, unless you change all your pages that reference Application("connString"), they will all fail, because this Application variable (your database connection string) is no longer being set where it needs to be.  Now, you can go and remove it, but as I said, you would need to go into every page that calls for it, and replace the Application("connString") with the actuall connection string for the database.

 

by: kevp75Posted on 2006-04-05 at 12:15:54ID: 16385276

everytime a person browses to your site, that file is run.

Yes you could put some code in a header.asp file to do the work you need it to do, but you would have to code it differently than what you have.  but then you would have to go into every file and make sure it is included

do me a favor.put this in your page:
response.write("username") & "_" & Session("MM_Username")

and see what it puts out

 

by: lukegriffiths110Posted on 2006-04-05 at 12:16:17ID: 16385281

The application tracks students. However it is only the admin who i want to have security. The student tracking just logs the students login time, user name and IP. The admin then logs in on a different login and can view these details. This all works but the admin needs to be secure. This is were the problem is if the admin doesn't log out and the sesion is stored a student could view th details.

 

by: kevp75Posted on 2006-04-05 at 12:18:33ID: 16385315

so then the rest of that code you removed will have to stay in global.asa, just like I said it would need to.

All that Application("Active") + 1 stuff is doing all the counting for you

 

by: lukegriffiths110Posted on 2006-04-05 at 12:21:12ID: 16385354

I don't need that tracked and it was removed from the database. It now only records the users ID, login time and IP I do not need to know who is online.

 

by: lukegriffiths110Posted on 2006-04-05 at 12:22:44ID: 16385376

The application works without the global.asa file.

 

by: kevp75Posted on 2006-04-05 at 12:23:45ID: 16385387

ok, then take it out.
AS I SAID BEFORE:
without:Application("connString") = "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\Inetpub\wwwroot\online_Users\Online.mdb;Uid=Admin;Pwd=pass;"
 in it you will have to go through every one of your files, and make sure to update every instance of Application("connString"), otherwise the whole application will fail.


AND:
now..there is a problem to this.   Problem is, if the user closes the window, goes to another page, or their computer freezes on them, session("sessionname") will not get set to "" unless the session timeout occurs.

Best bet is to use some kind of javascript to detect if the user has clicked the X, or hit ALT-F4, then use some autoclosing popup to set session("sessionname") = ""

Or.....you could lower you session timeout in your server.  Problem is with this is what if you have a user logged in to the site longer than your timeout.....

Personally, I wold nix the whole session variable idea, and just use cookies.  if you set no expiry on the cookie, it is only valid until that user closes the browser.  If security is an issue, set the cookie using some kind of encryption, and where you need to get the value from the cookie, decrypt it.

To set a cookie use:response.cookies("cookiename") = value
to get a cookie use:variable = request.cookies("cookiename")

 

by: lukegriffiths110Posted on 2006-04-05 at 12:26:13ID: 16385413

Okay the cookie idea seems the best as security is not that important.

 

by: kevp75Posted on 2006-04-05 at 12:30:33ID: 16385461

that's probably your best bet., just go and replace:
session("username") = usersname '(setting the session variable)

with:
response.cookies("username") = usersname  '(setting the cookie)

and where you would:
usersname = session("username")  '(requesting the session variable)

replace it with:
usersname = request.cookies("username")   '(requesting the cookie)

 

by: kevp75Posted on 2006-04-05 at 12:30:59ID: 16385468

Q4U:  before you switch to cookies

 

by: lukegriffiths110Posted on 2006-04-05 at 12:31:50ID: 16385481

yes

 

by: kevp75Posted on 2006-04-05 at 12:32:19ID: 16385488

I noticed in some code that there is: Session("MM_Username")

have you tried to replacing your session("username") with Session("MM_Username")???

 

by: lukegriffiths110Posted on 2006-04-05 at 12:34:57ID: 16385517

I could however when you logout the session returns "" the MM_userNAME I think is to do with dream weaver i will give it a go. but the cookies seems like a great alternative and easy to implement.

 

by: kevp75Posted on 2006-04-05 at 12:37:46ID: 16385552

it is relatively easy.  I usually only use cookies, and if I need some added security on them, I use an encryption function

 

by: lukegriffiths110Posted on 2006-04-05 at 12:38:51ID: 16385567

I don't think i will but i'm not finding it that easy

 

by: lukegriffiths110Posted on 2006-04-05 at 12:41:10ID: 16385594

what is wrong here should it be<>

<%
if usersname = request.cookies("username")
     Response.Redirect("adminlogin.asp?error=2")
else
%>
<html>
<Head>
<link href="css/css.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--

div.test {
     width: 500px;
     height:300px

 

by: kevp75Posted on 2006-04-05 at 12:51:02ID: 16385732

<%
if usersname = request.cookies("username")
     Response.Redirect("adminlogin.asp?error=2")
else
%>

should be

<%
if request.cookies("username") = ""
     Response.Redirect("adminlogin.asp?error=2")
else
%>

 

by: lukegriffiths110Posted on 2006-04-05 at 12:58:20ID: 16385826

For the logout what is the best way to clear the cookie, at the moment it clears session by:-

<%
Session.Abandon()
Session.Contents.RemoveAll()
response.redirect("adminlogin.asp")
%>

 

by: kevp75Posted on 2006-04-05 at 13:01:32ID: 16385852

replace it with:

<%
request.cookies("username") = ""
response.rediret("adminlogin.asp")
%>

 

by: lukegriffiths110Posted on 2006-04-05 at 13:07:07ID: 16385914

I get this error:-

Script error detected at line 1.
Source line: request.cookies("username") = ""
Description: Type mismatch: 'request.cookies'

 

by: kevp75Posted on 2006-04-05 at 13:10:07ID: 16385940

sorry bout that....should be response.cookies("username") = ""

 

by: lukegriffiths110Posted on 2006-04-05 at 13:12:55ID: 16385969

Last problem the cookie is being stored as when you logout you are able to click on the back button.

 

by: kevp75Posted on 2006-04-05 at 13:20:54ID: 16386048

you will have to add:

<%
Response.Expires = -1
%>

to each page.  what is happening there is the previous page is cached.  using this response.expires = -1 will prevent that page from being cached

 

by: lukegriffiths110Posted on 2006-04-05 at 13:25:58ID: 16386100

Okay i think everything is working now. Thanks for all your help you are truly an generous expert. I am going to leave full testing till 2moz as i will not go to sleep knowing something is not working. Thanks again luke

 

by: kevp75Posted on 2006-04-05 at 13:28:26ID: 16386120

:)

np

 

by: kevp75Posted on 2006-04-05 at 19:08:01ID: 16388394

luke, there's someone I'm trying to help out here (http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_21803432.html), and I'm wondering if I can let him know who you are to maybe discuss or help each other out with issues with Baby Web Server?

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...