Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sessions and DLL's

Status
Not open for further replies.
gary,

to set a cookie using a dl try this

Code:
Dim Response As System.Web.HttpResponse = 
System.Web.HttpContext.Current.Response

Response.Cookies.Add(New Web.HttpCookie("MyCookie", "MyValue"))

I googled session vars and dll's and came up with this


You do not have to make a webclass. Reference "Microsoft Active Server
Pages Object Library" (I think you will have had to install PWS or IIS
first for ASP.DLL to be present on your system). In the class method you
invoke from the ASP page you can receive Session. For example your class
could have

Code:
Public Sub Perform_Function(ByVal strFunction as Variant, ByVal aspSession
as Session)

'down in here you can do stuff like
Debug.Print aspSession("somevar")
aspSession("somevar") = "DLL Says Hi Right Back"

End Sub

asp would be
<%
Option Explicit

Dim aspFunction
Dim objSomeDll

Set objSomeDll = Server.CreateObject(&quot;YourDLL.SomeNeatClass&quot;)

aspFunction = &quot;WHATEVER&quot;
Session(&quot;somevar&quot;) = &quot;Greetings from ASP Page&quot;
objSomeDll.Perform_Function aspFunction, Session
Response.Write Session(&quot;somevar&quot;)

Set objSomeDll = Nothing
%>

hope this helps

simon
 
I was going nowhere with that, couldn't find any references to use system.web in VB6 but I did find this for anyone else trying to use the ASP objects - session,cookies, server etc from within a vb dll. Just add this into the dll

Public Function OnStartPage(aspScriptingContext As ScriptingContext)
On Error Resume Next
Set Request = aspScriptingContext.Request
Set Response = aspScriptingContext.Response
Set Server = aspScriptingContext.Server
Set Session = aspScriptingContext.Session
Set Application = aspScriptingContext.Application
End Function

...and then you have access to all objects exactly as you would in an asp page e.g.

Private Request As IRequest
Private Response As IResponse
Private Server As IServer
Private Session As ISessionObject
Private Application As IApplicationObject

Public Function OnStartPage(aspScriptingContext As ScriptingContext)
On Error Resume Next
Set Request = aspScriptingContext.Request
Set Response = aspScriptingContext.Response
Set Server = aspScriptingContext.Server
Set Session = aspScriptingContext.Session
Set Application = aspScriptingContext.Application
End Function

Public Sub MakePage()
Dim objctx As ObjectContext
Set objctx = GetObjectContext()

Response.Write Session(&quot;test&quot;)
Response.Write Request.Cookies(&quot;username&quot;)

Set objctx = Nothing
End Sub

 
just to give you some reference to simon's post


I was going nowhere with that
show a bit of appreciation for the try and help provided man

hey, thanks for the post but,,,,

___________________________________________________________________
onpnt2.gif

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top