Jump to content
Sign in to follow this  

How to set a cookie

Recommended Posts


I am trying to set a local cookie preferably without opening the browser window.  I can see how to read a cookie but setting a cookie is not clear.

#include <msgboxConstants.au3>
#include <Array.au3>
#include <IE.au3>

Global $oIE = _IECreate("google.com")
Global $oCookie = $oIE.document.cookie

msgbox($MB_SYSTEMMODAL, "", $oCookie) ; check for string

Global $oCookieValues = StringSplit($oCookie, ";")
_ArrayDisplay($oCookieValues) ; check for Array

;$oIE.document.cookie = name1=value1;name2=value2
$oIE.document.cookie = myCookie=test;name2=value2

I think this will set my cookie?

$oIE = _IECreate("www.google.com")

$oIE.document.cookie = "test_cookie=one; path=/;"
ConsoleWrite($oIE.document.cookie & @CRLF)
$oIE.document.cookie = "test_cookie=two; path=/;"
ConsoleWrite($oIE.document.cookie & @CRLF)
Edited by charon

Share this post

Link to post
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

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.