Print Page | Close Window

Prob wiv ’Session.Contents.Remove’

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=11813
Printed Date: 31 March 2026 at 1:36am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Prob wiv ’Session.Contents.Remove’
Posted By: WebDever
Subject: Prob wiv ’Session.Contents.Remove’
Date Posted: 15 September 2004 at 10:10am

I'm recieving this error on a log out page, made by Dreamweaver:

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'Session.Contents.Remove'

/admin/adminindex.asp, line 11

Here's the source code:

<%@LANGUAGE="VBSCRIPT"%>
<%
Response.Expires = 60
Response.Expires = Now() - 1
Response.CacheControl = "no-cache"
%>
<%
' *** Logout the current user.
MM_Logout = CStr(Request.ServerVariables("URL")) & "?MM_Logoutnow=1"
If (CStr(Request("MM_Logoutnow")) = "1") Then
  Session.Contents.Remove("MM_Username")
  Session.Contents.Remove("MM_UserAuthorization")
  MM_logoutRedirectPage = "../default.asp"
  ' redirect with URL parameters (remove the "MM_Logoutnow" query param).
  if (MM_logoutRedirectPage = "") Then MM_logoutRedirectPage = CStr(Request.ServerVariables("URL"))
  If (InStr(1, UC_redirectPage, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
    MM_newQS = "?"
    For Each Item In Request.QueryString
      If (Item <> "MM_Logoutnow") Then
        If (Len(MM_newQS) > 1) Then MM_newQS = MM_newQS & "&"
        MM_newQS = MM_newQS & Item & "=" & Server.URLencode(Request.QueryString(Item))
      End If
    Next
    if (Len(MM_newQS) > 1) Then MM_logoutRedirectPage = MM_logoutRedirectPage & MM_newQS
  End If
  Response.Redirect(MM_logoutRedirectPage)
End If
%>
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers="full"
MM_authFailedURL="noaccess.htm"
MM_grantAccess=false
If Session("MM_Username") <> "" Then
  If (false Or CStr(Session("MM_UserAuthorization"))="") Or _
         (InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization")) >=1) Then
    MM_grantAccess = true
  End If
End If
If Not MM_grantAccess Then
  MM_qsChar = "?"
  If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
  MM_referrer = Request.ServerVariables("URL")
  if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
  MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
  Response.Redirect(MM_authFailedURL)
End If
%>

Help, what should I do?

--Ashley--



-------------
--Ashley



Replies:
Posted By: dpyers
Date Posted: 15 September 2004 at 8:00pm

The statement as it stands looks ok. You may want to check if MM_Username rseally exists - although I don't think that matters. But if the session's already been dropped it will matter.

Checl your session variables with...

for each x in Session.Contents
     Response.Write(x & "=|" & Session.Contents(x) & "|<br />")
next

If they look ok at this point in your code, try commenting out
Response.Expires = Now() - 1
Response.CacheControl = "no-cache"



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: WebDever
Date Posted: 16 September 2004 at 4:25am

Still doesn't work? Same error, do you think it something to do with the version of ASP on the server, which in ASP 2.0??

Thanks :)



-------------
--Ashley


Posted By: dpyers
Date Posted: 16 September 2004 at 11:10am

It might. IIRC, there were some differences in how sessions were handled between 2.0 and 3.0 and something with collections - but I forget the details. Might want to replace

Session.Contents.Remove("MM_Username")
with
Session("MM_Username") = ""

And see if you can get past that statement.



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: WebDever
Date Posted: 16 September 2004 at 11:14am

Thanks, it works fine!



-------------
--Ashley



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net