FFREDIANELLI Posted May 17, 2018 Posted May 17, 2018 How to Delete a Cookie ? i wold like to delete all the cookies starting with 'wmn_*' , is it possible ? or do i have to set the value to '' one by one ? Quote
Sherzod Posted May 18, 2018 Posted May 18, 2018 Hi, You can use something like this: procedure TMainForm.UniButton1Click(Sender: TObject); var I : Integer; begin if UniApplication.Cookies.Count > 0 then for I := 0 to UniApplication.Cookies.Count - 1 do if Pos('wmn_', UniApplication.Cookies[I]) <> 0 then UniApplication.Cookies.SetCookie(UniApplication.Cookies[I],'',Date-1); end; Quote
FFREDIANELLI Posted May 18, 2018 Author Posted May 18, 2018 Hi, You can use something like this: procedure TMainForm.UniButton1Click(Sender: TObject); var I : Integer; begin if UniApplication.Cookies.Count > 0 then for I := 0 to UniApplication.Cookies.Count - 1 do if Pos('wmn_', UniApplication.Cookies[I]) <> 0 then UniApplication.Cookies.SetCookie(UniApplication.Cookies[I],'',Date-1); end; Just for others that may use the same code, it only worked after removing everithing after the '=' sign that came with the UniApplication.Cookies , it return 'wmn_nome=fabio' that is not the name of the cookie, so the code that worked changed to: var I: integer; begin if UniApplication.Cookies.Count > 0 then for I := 0 to UniApplication.Cookies.Count - 1 do if Pos('wmn_', UniApplication.Cookies) <> 0 then UniApplication.Cookies.SetCookie(copy(UniApplication.Cookies,1,pos('=',UniApplication.Cookies)-1), '', Date - 1); UniApplication.Terminate('Safe logout executed , Thanks !'); end; Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.