0
votes

In PHP I can choose to use a particular Session by using Session_id() as a setter.

Is there any similar functionality in Classic ASP/VBScript? I have an VBScript site that, depending on the page, is either called directly from the browser or internally via HTTP. Unfortunately ASP treats these as two separate sessions, because the User's computer calls one and the Server itself calls the other. I want to tell the Server calls, "Hey, use Session 123456" so it can share info with the user calling pages directly.

Any advice? Any way to change or name the Session being used on a page?

2
Can you give an example? The Server calls aren't going to share cookies with the browser either... - Stephen R
There's no such built-in method for ASP's Session. But you can manually set cookie header (by parsing the session cookie's value from Request.ServerVariables("ALL_RAW") or something like) within your internal request. - Kul-Tigin
Where do you make internal requests from? Asking because, a deadlock happens if both are the ASP. - Kul-Tigin
That might work. So... get the VBScript session id and then manually pass the same cookie as I make the internal requests. Nice approach. Related? stackoverflow.com/questions/7331172/… - Stephen R
:) There's no easy way to tell the Server "Hey, use Session #1". because of ASP's session stored in-process and the access is single threaded. While the request is working with session #1 you can't access session #1 from an additional request, a deadlock and finally request time out happens. But it's easy to access from somewhere else. PHP for example stackoverflow.com/a/37060660 - Kul-Tigin

2 Answers

3
votes

There's no built-in method like PHP's Session_id() in ASP Classic.

ASP's Session object has a strict locking mechanism that guarantees consistency of the state, so this prevents you to make additional requests with the same session identifier within the same application pool.

On the other hand it's easy to implement a bridge to share the session state with a different platform like PHP under the same domain.


How to access ASP classic session variable from PHP?

0
votes

I'm not sure that I understood your problem correct. You need a variable for each user? Why didn`t you use an application variable?

<%
    x=session.sessionID
    if not instr(application("x"),x)>0 then
       application("x")=application("x") & x &";"
    end if

    aArr=split(application("x"),";")

    for i=0 to ubound(aArr)
        REM this will show you all used session.variables
        response.write aArr(i)&"<br>"
    next
%>