1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
   | Function getSession(strDomain As String)
    Dim iWnd As SHDocVw.ShellWindows, i As IWebBrowser2, idoc As HTMLDocument, theCook As String, temp
 
    On Error Resume Next
 
    Set iWnd = New SHDocVw.ShellWindows
    For Each i In iWnd
        temp = "": temp = i.Type
        If temp = "Document HTML" Then
            Set idoc = i.document
            If idoc.domain Like ("*" & strDomain & "*") Then
                theCook = idoc.cookie
                temp = Split(theCook, "session=")
                If InStr(1, theCook, "session=") > 0 Then getSession = CStr(Split(temp(1), ";")(0))
 
                Exit Function
            End If
        End If
    Next
end function | 
Partager