dcsimg
Results 1 to 6 of 6

Thread: How to share ASP classic session variable from ASP to VB6?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2019
    Posts
    3

    How to share ASP classic session variable from ASP to VB6?

    Good morning,

    I registered in this forum because I'm working on a project developed in classic Asp with vb script that calls a VB6 dll library with the Server.CreateObject method.

    I created a session variable in ASP and would like to read it from VB6 dll.

    I searched a lot on the web but I didn't find solutions. This is data related to the user connected, then stored in a session variable.

    My goal is to get to know the connected user by the VB6 dll.

    Can you help me please?

  2. #2
    New Member
    Join Date
    Jul 2019
    Posts
    8

    Resolved Re: How to share ASP classic session variable from ASP to VB6?

    You only need to create a Sub in your VB6 to pass the data, and call it from ASP:
    Code:
    <%
    
    Dim Obj
    
    Obj = Server.CreateObject("MyDLL.MyClass")
    Obj.DataFromASP Session("MyVariable")
    ...
    Set Obj = Nothing
    
    %>
    The code to add in the public class ("MyClass") of your DLL ("MyDLL") could be like this:
    Code:
    dim ASPData As Variant
    
    Public Sub DataFromASP(Data as Variant)
        ASPData = Data
    End Sub
    Disclaimer: Code not tested

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2019
    Posts
    3

    Re: How to share ASP classic session variable from ASP to VB6?

    Hi Leo, thanks for help me.
    Is there a way to pass the session variable implicitly, without passing it as a parameter?

    Code:
    Obj.DataFromASP Session("MyVariable")

  4. #4
    New Member
    Join Date
    Jul 2019
    Posts
    8

    Re: How to share ASP classic session variable from ASP to VB6?

    There is other alternative. You can define two Subs, "OnStartPage" and "OnEndPage" in your class. For example:
    Code:
    Dim vSC As ScriptingContext
    
    Public Sub OnStartPage(SC As ScriptingContext)
        Set vSC = SC
    End Sub
    
    Public Sub OnEndPage()
        Set vSC = Nothing
    End Sub
    (You'll need to add a reference to "Microsoft Active Server Pages Object Library" to the project)

    IIS calls this subs automatically when your object is created (Server.CreateObject) and destroyed (Set Obj = Nothing). This way you don't need "DataFromASP" Sub. The ScriptingContext object gives you access to all ASP objects (Server, Response, ...)

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2019
    Posts
    3

    Re: How to share ASP classic session variable from ASP to VB6?

    Thanks leo, you solved a huge problem for me.
    I haven't worked on vb6 for many years and I didn't know how to go on.

    Thank you very much


    Marco

  6. #6
    New Member
    Join Date
    Jul 2019
    Posts
    8

    Re: How to share ASP classic session variable from ASP to VB6?

    i'm glad to help you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width