Jump to content

Stilgar help me please


Recommended Posts

Can you make a funtion that read/ write firefox cookies?. Like: _FFgetcookies($site,$name) _FFsetcookies($site,$name,$value). Please help me

You can try them:

Func _FF_CookieGet($sURL, $sName = "")
    ;https://developer.mozilla.org/en/Code_snippets/Cookies
    If Not __FFCheckURL($sURL) Then
        SetError(__FFError("_FF_CookieGet", $_FF_ERROR_InvalidDataType, "(URL) $sURL: " & $sURL))
        Return ""
    EndIf
    Local $sCmd = 'Components.classes["@mozilla.org/cookieService;1"].getService(Components.interfaces.nsICookieService).getCookieString(Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).newURI("' & $sURL & '", null, null), null);'
    Local $sRet = _FFCmd($sCmd)
    If @error Then Return SetError(1, 0, "")

    If $sName Then
        $sRet = StringRegExpReplace($sRet, '^(.*?;\s*)*' & $sName & '=(.*?)(;|$).*', '$2')
        If Not @extended Then Return SetError(1, 0, $sRet)
    EndIf

    Return $sRet
EndFunc   ;==>_FF_CookieGet

Func _FF_CookieSet($sURL, $sName, $sValue)
    ;https://developer.mozilla.org/en/Code_snippets/Cookies
    If Not __FFCheckURL($sURL) Then
        SetError(__FFError("_FF_CookieGet", $_FF_ERROR_InvalidDataType, "(URL) $sURL: " & $sURL))
        Return ""
    EndIf
    Local $sCmd = 'Components.classes["@mozilla.org/cookieService;1"].getService(Components.interfaces.nsICookieService).setCookieString(Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).newURI("' & $sURL & '", null, null), null, "' & $sName & '=' & $sValue & '", null);'
    Local $sRet = _FFCmd($sCmd)
    If @error Then Return SetError(1, 0, "")

    Return $sRet
EndFunc   ;==>_FF_CookieSet
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...