From: Richard on
I have just gone from XP to Win7 and have run into a cookie issue. I
wonder
if anyone here has managed to successfully set a cookie in IE under
Win7 or Vista...?

Here's what works in XP:

Private Declare Function InternetSetCookie Lib "wininet.dll" _
Alias "InternetSetCookieA" _
(ByVal lpszUrlName As String, _
ByVal lpszCookieName As String, _
ByVal lpszCookieData As String) As Boolean

then call it like this:
retValue = InternetSetCookie("http://www.website.com/", cookiename,
cookievalue & "; expires = Sat,02-Jan-2011 00:00:00 GMT")
=============== That does not work in Win7 or Vista ================

Here's what I tried:
Private Declare Function SInternetSetCookie Lib "ieframe.dll" _
Alias "IESetProtectedModeCookie" _
(ByVal lpszURL As String, _
ByVal lpszCookieName As String, _
ByVal pszCookieData As String, _
ByVal dwFlags As Long) As Boolean

then call it like this:
retValue = SInternetSetCookie("http://www.website.com/", cookiename,
cookievalue & "; expires = Sat,02-Jan-2011 00:00:00 GMT", 0)
=============== That also does not work in Win7 or Vista
================

This is causing me major issues...
From: Richard on
On Jun 22, 11:26 am, Richard <a1carbro...(a)gmail.com> wrote:
> I have just gone from XP to Win7 and have run into a cookie issue. I
> wonder
> if anyone here has managed to successfully set a cookie in IE under
> Win7 or Vista...?
>
> Here's what works in XP:
>
> Private Declare Function InternetSetCookie Lib "wininet.dll" _
> Alias "InternetSetCookieA" _
> (ByVal lpszUrlName As String, _
> ByVal lpszCookieName As String, _
> ByVal lpszCookieData As String) As Boolean
>
> then call it like this:
> retValue = InternetSetCookie("http://www.website.com/", cookiename,
> cookievalue & "; expires = Sat,02-Jan-2011 00:00:00 GMT")
> =============== That does not work in Win7 or Vista ================
>
> Here's what I tried:
> Private Declare Function SInternetSetCookie Lib "ieframe.dll" _
> Alias "IESetProtectedModeCookie" _
> (ByVal lpszURL As String, _
> ByVal lpszCookieName As String, _
> ByVal pszCookieData As String, _
> ByVal dwFlags As Long) As Boolean
>
> then call it like this:
> retValue = SInternetSetCookie("http://www.website.com/", cookiename,
> cookievalue & "; expires = Sat,02-Jan-2011 00:00:00 GMT", 0)
> =============== That also does not work in Win7 or Vista
> ================
>
> This is causing me major issues...

In case anyone is interested, it looks like it cannot be done using
VBA. Not unless you run XP or below. It simply is not possible to set
cookies directly using VBA into Internet Explorer.