Cookie Spiechern und inhalt auslesen

  • VB.NET

    Cookie Spiechern und inhalt auslesen

    Hallo Leute


    Ich Speicher den Cookie und möchte aus diesen dann die sid (Session Id) auslesen.
    Damit ich diese später in mein eigenen Browser laden kann.

    Nur leider Bekomme ich nur, den ganzen Queltext ausgelesen, und nicht nur den sid.

    Was mache ich falsh? :D
    Habe mich noch nie mit Cookies ausernander gesetzt, bitte um hilfe.


    VB.NET-Quellcode

    1. Imports System
    2. Imports System.Net
    3. Imports System.IO
    4. Imports System.Text
    5. Imports System.Text.RegularExpressions
    6. Public Class LoginForm1
    7. Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
    8. If UsernameTextBox.Text = "" Then
    9. MsgBox("Name eintippen")
    10. ElseIf PasswordTextBox.Text = "" Then
    11. MsgBox("Password eintippen")
    12. Else
    13. Dim URL = "http://www.darkorbit.com"
    14. Dim Request As HttpWebRequest = CType(WebRequest.Create(URL), HttpWebRequest)
    15. Request.Method = "POST"
    16. Request.ContentType = "application/x-www-form-urlencoded"
    17. Dim Post As String = "loginForm_default_username=" & UsernameTextBox.Text & "&loginForm_default_password=" & PasswordTextBox.Text & "&loginForm_default_login_submit=Login"
    18. Dim byteArray() As Byte = Encoding.UTF8.GetBytes(Post)
    19. Request.ContentLength = byteArray.Length
    20. Dim DataStream As Stream = Request.GetRequestStream()
    21. DataStream.Write(byteArray, 0, byteArray.Length)
    22. DataStream.Close()
    23. Dim Response As HttpWebResponse = Request.GetResponse()
    24. DataStream = Response.GetResponseStream()
    25. Dim reader As New StreamReader(DataStream)
    26. Dim ServerResponse As String = reader.ReadToEnd()
    27. Dim Request2 As HttpWebRequest = HttpWebRequest.Create(URL)
    28. Request2.CookieContainer = New CookieContainer()
    29. Dim Response2 As HttpWebResponse = Request2.GetResponse
    30. Response2.Cookies = Request2.CookieContainer.GetCookies(Request2.RequestUri)
    31. Dim Reader2 As IO.StreamReader = New IO.StreamReader(Response2.GetResponseStream)
    32. For Each SetCookie As Cookie In Response2.Cookies
    33. Debug.Print(SetCookie.Value)
    34. Next
    35. reader.Close()
    36. DataStream.Close()
    37. Response.Close()
    38. If InStr(ServerResponse, "Serverauswahl") Then
    39. MessageBox.Show("Login OK")
    40. Form2.Show()
    41. Me.Hide()
    42. Dim URL2 = ComboBox1.SelectedItem & ".darkorbit.bigpoint.com/indexInternal.es?action=internalStart&dosid="
    43. Form2.WebBrowser1.Navigate(URL2)
    44. Form2.RichTextBox2.Text = (URL2)
    45. Dim path As String = "settings\"
    46. Dim file As System.IO.FileStream
    47. If Not System.IO.File.Exists(path & UsernameTextBox.Text & ".pixy") Then
    48. file = System.IO.File.Create(path & UsernameTextBox.Text & ".pixy")
    49. file.Close()
    50. Dim writeFile As System.IO.TextWriter = New _
    51. StreamWriter(path & UsernameTextBox.Text & ".pixy")
    52. writeFile.Write(UsernameTextBox.Text & ";" & PasswordTextBox.Text & ";" & ComboBox1.SelectedItem)
    53. writeFile.Flush()
    54. writeFile.Close()
    55. Return
    56. ElseIf System.IO.File.Exists(path & UsernameTextBox.Text & ".pixy") Then
    57. Dim writeFile As System.IO.TextWriter = New _
    58. StreamWriter(path & UsernameTextBox.Text & ".pixy")
    59. writeFile.Write(UsernameTextBox.Text & ";" & PasswordTextBox.Text & ";" & ComboBox1.SelectedItem)
    60. writeFile.Flush()
    61. writeFile.Close()
    62. Return
    63. End If
    64. Else
    65. MessageBox.Show("Login nicht OK")
    66. End If
    67. End If
    68. End Sub
    69. Private Sub Cancel_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
    70. Me.Close()
    71. End Sub
    72. Private Sub ComboBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.VisibleChanged
    73. ComboBox2.Items.AddRange(System.IO.Directory.GetFiles("settings\", "*.pixy").ToArray)
    74. End Sub
    75. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    76. If ComboBox2.SelectedIndex = -1 Then
    77. MessageBox.Show("Du mus eine Login datei Auswählen")
    78. Else
    79. Dim path As String = "settings\"
    80. Dim ReadFile As System.IO.TextReader = New _
    81. StreamReader(path & "seby1302.pixy")
    82. ReadFile.Close()
    83. Return
    84. End If
    85. End Sub
    86. End Class


    Debug.Print(SetCookie.name)
    gibt aus..
    dosid
    BP_DO_tracking_viewToReg_view
    bpLandingPage_fallback
    Debug.Print(SetCookie.value)
    d8df2c464e2e31ab10639140a73a35c4
    1
    darkorbit.com/


    nur wie lade ich die value 2 aus dem cookie in meinem link?

    VB.NET-Quellcode

    1. ComboBox1.SelectedItem & ".darkorbit.bigpoint.com/indexInternal.es?action=internalStart&dosid="& SetCookie.value = 2

    Lg an alle

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „seby1302“ ()