FFREDIANELLI Posted May 17, 2018 Share 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 ? Link to comment Share on other sites More sharing options...
Sherzod Posted May 18, 2018 Share 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; Link to comment Share on other sites More sharing options...
FFREDIANELLI Posted May 18, 2018 Author Share Posted May 18, 2018 Thanks Link to comment Share on other sites More sharing options...
FFREDIANELLI Posted May 18, 2018 Author Share 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; Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now