DBecker
31st December 2004 13:57 UTC
Reading a cookie and writing to the registry
Hi Guys,
I am trying to figure out how to:
1) Locate the Window's cookie directory.
2) Find a specific cookie inside it.
3) Read it.
4) write it into the computer's registry.
Searched all over. Couldn't find documents. Please please help! :)
Thanks,
Dave
Afrow UK
31st December 2004 14:15 UTC
$COOKIES is in the NSIS documentation :p
-Stu
Afrow UK
31st December 2004 14:28 UTC
As for finding the cookie, you can use FindFirst, FindNext etc
Push $R0
FindFirst $R0 $R1 "$COOKIES\*.*"
Loop:
IfErrors Done
StrCpy $R2 $R1 "" -15
StrCmp $R2 "@website[1].txt" 0 NextCookie
FileOpen $R2 "$COOKIES\$R1" "r"
CookieLoop:
ClearErrors
FileRead $R2 $R3
IfErrors CookieDone
## Find cookie id
Push $R3
Call TrimNewLines
Pop $R3
StrCmp $R3 "mycookieID" 0 CookieLoop
## Get value
FileRead $R2 $R3
Push $R3
Call TrimNewLines
Pop $R3
WriteRegStr HKCU "Software\myapp" "Cookie" "$R3"
CookieDone:
FileClose $R2
Goto Done
NextCookie:
ClearErrors
FindNext $R0 $R1
Goto Loop
Done:
FindClose $R0
Note that this isn't tested!
Edit: You need the TrimNewLines function in your script.
-Stu