Cookies hinzufügen/bearbeiten/löschen

  • Guten Abend

    Ich bin auf der Suche nach Funktionen, welche mir erlauben die Cookies hinzuzufügen / bearbeiten und löschen.
    Gefunden habe ich über Google nicht viel, nur diesen Thread und folgende Funktionen zum Cookies auslesen.

    Cookies auslesen
    [autoit]

    ;; ======= ;;
    ;; EXAMPLE ;;
    ;; ======= ;;
    #include <FF.au3>
    #include <Array.au3>
    _FFStart()
    $cookie_name = _FFGetSingleCookie('ID', 'google') ; receives single cookie - first one containing 'ID' (case sensitive!) in name, and 'google' in host
    MsgBox(0, '', $cookie_name)

    [/autoit] [autoit][/autoit] [autoit]

    $COOKIE_ARRAY = _FFGetSingleCookie('id', '', True) ; receives 3-elements array with cookie: name, value, host of a first cookie, where name contains 'id' (case sensitive!)
    _ArrayDisplay($COOKIE_ARRAY)

    [/autoit] [autoit][/autoit] [autoit]

    $timer = TimerInit()
    $global_cookie_array = _FFGetAllCookies() ; returns all cookies in 2dimensional, 3column array with cookies NAME, VALUE and HOST
    MsgBox(0, '', TimerDiff($timer)) ; as you can see it's pretty fast... BUT ArrayDisplaying is rather slow with many cookies...

    [/autoit] [autoit][/autoit] [autoit]

    _ArrayDisplay($global_cookie_array)
    MsgBox(0, '', TimerDiff($timer) )
    ;; ======= ;;
    ;; ======= ;;

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: _FFGetAllCookies
    ; Description:: Returns array with _ALL_ cookies
    ; Parameter(s): - none -
    ; Requirement(s): FF.au3
    ; Return Value(s): On succes: 2-dimensional array with all cookies (column names:)
    ; NAME VALUE HOST
    ; On failure: '_FFCmdErr'
    ;
    ;===============================================================================
    Func _FFGetAllCookies()
    ;~ © 4ggr35510n ©

    [/autoit] [autoit][/autoit] [autoit]

    Local $aT, $aTA
    $sCS = _FFCmd("var cookiestring='';var cookieManager=Components.classes['@mozilla.org/cookiemanager;1'].getService(Components.interfaces.nsICookieMana"& _
    "ger);var iter=cookieManager.enumerator;while(iter.hasMoreElements()){var cookie=iter.getNext();if(cookie instanceof Components.interfaces.nsICookie){"& _
    "cookiestring+=cookie.name+'='+cookie.value+'='+cookie.host+';';}};cookiestring;")
    $aTA = StringSplit($sCS, ';')
    Local $aCA[$aTA[0]-1][3]
    For $i = 1 to $aTA[0] - 1
    $aT = StringSplit($aTA[$i], '=')
    $aCA[$i-1][0] = $aT[1]
    If $aT[0] > 3 Then ; in case that cookie.value contains equals signs '=' [ it's more common then you think! ]
    For $j = 2 to $aT[0] - 1
    $aCA[$i-1][1] &= $aT[$j] & '='
    Next
    $aCA[$i-1][1] &= $aT[$aT[0]-1]
    Else
    $aCA[$i-1][1] &= $aT[2]
    EndIf
    $aCA[$i-1][2] = $aT[$aT[0]]
    Next
    Return $aCA

    [/autoit] [autoit][/autoit] [autoit]

    ;~ © 4ggr35510n ©
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: _FFGetSingleCookie
    ; Description:: Returns cookie with a given name
    ;
    ; Parameter(s):
    ; $sName - Name of a cookie you want receive, used in StringRegExp as a pattern
    ; $sUrl - Optional: (default = '') : url (host) of a cookie, used in StringRegExp as a pattern
    ; $iMode - Optional: (Default = False) : determines is Return Value a string containing value of cookie, or 3-elements array containing
    ; name, value and host of a cookie
    ; | False - returns string (cookie.value)
    ; | True - returns array (cookie.name, cookie.value and cookie.host)
    ; Requirement(s): FF.au3
    ; Return Value(s): On succes: Cookie value or 3-elements array
    ; On failure (no cookie matches given sName and sUrl pattern): -1
    ;
    ;===============================================================================
    Func _FFGetSingleCookie($sName, $sUrl = '', $iMode = False)
    ;~ © 4ggr35510n ©

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    If $sURL = Default Then $sUrl = ''
    Local $aCA = _FFGetAllCookies()
    If $iMode Then
    Local $aOut[3]
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 0 To UBound($aCA) -1
    If StringRegExp($aCA[$i][0], $sName, 0) And StringRegExp($aCA[$i][2], $sURL, 0) Then
    Switch $iMode
    Case False
    Return $aCA[$i][1]
    Case True
    $aOut[0] = $aCA[$i][0]
    $aOut[1] = $aCA[$i][1]
    $aOut[2] = $aCA[$i][2]
    Return $aOut
    EndSwitch
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    Return -1

    [/autoit] [autoit][/autoit] [autoit]

    ;~ © 4ggr35510n ©
    EndFunc

    [/autoit]

    Gibt es bereits Funktionen um Cookies hinzuzufügen / bearbeiten und löschen, welche ich einfach nicht gefunden habe?

    Gruss Fabian

  • In AutoIt gibt es noch nichts Aber es gibt genügend FF-Erweiterungen, aus denen du den nötigen JS-Code auslesen kannst, den du für die Funktionen brauchst.