0

The project I'm working on is integrating PHP written features / pages into an ASP written site. I'm trying to create a piece of ASP code that destroys ASP sessions when I'm on my PHP pages. I have no prior experience with ASP so forgive me for my ignorance.

So, what I plan to do is to create a simple html link on my PHP pages the points to an ASP page which I want to use to destroy the ASP sessions. I've tried doing the method Session.Abandon, set Session("name") = nothing, and Session("name") = "nothing". Unfortunately, all these methods do not work.

I'm at a lost and I've searched everywhere what could possibly be wrong. Ideas anyone?

Thanks in advance!

UPDATE: Is it a factor that the Sessions are originally created from a VBScript?

4 Answers4

1

In classic ASP, use Session.Abandon

Control Freak
  • 12,965
  • 30
  • 94
  • 145
1

All you need to do is on the page you want the sessions to be dismissed from use:

Session.Contents.RemoveAll()

This will instantly clear all session's you have as soon as the page is run

ByronMcGrath
  • 365
  • 2
  • 3
  • 20
0

Perhaps these are not working because you are not "taking a trip to the server"? In other words, if you are on a page that has this code:

session("s_name_user")="mommy"
session.abandon
print session("s_name_user") 'hahaha

Then it will look like session.abandon did not work because the session variable retained its value. BUT if you do this:

session("s_name_user")="mommy"
session.abandon
response.redirect("page2.asp")

and page2.asp has this:

print session("s_name_user") 'hahaha

then we will see the session variable lost its value. By the way, don't try the "print" command.

ScotterMonkey
  • 1,007
  • 12
  • 25
0

If you want to remove the content of a specific session, you should use Session.Contents.Remove("session_name"). If you want to remove all of the session's contents, you should use Session.Contents.RemoveAll(). If you want to remove all the sessions including their content, you should use Session.Abandon. Once you removed or added any session, you can run the following code to see all of the active sessions:

Response.Write("Total Session: " & Session.Contents.Count & "<hr>")
For Each item in Session.Contents
    Response.Write(item & ": " & Session.Contents(item) & "<br>")
Next
Jay
  • 1,384
  • 1
  • 17
  • 30