SergioFeitoza Posted March 9, 2021 Share Posted March 9, 2021 Some time ago I set a login name and a password as default to avoid to retype everytime during my development.( see figure) Now I am trying to remove them to enable a normal use of typing both. However I do not remember where I fixed these defaults I think it is related to this cookie Inside my code edtLogin.Text := UniApplication.Cookies.GetCookie( '_loginname' ); edtSenha.Text := UniApplication.Cookies.GetCookie( '_pwd' ); but the question is : where the default _loginname and _pwd came from ? Can you help me? I think I am not telling about the property “empty text” Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 10, 2021 Share Posted March 10, 2021 5 hours ago, SergioFeitoza said: I think it is related to this cookie Inside my code edtLogin.Text := UniApplication.Cookies.GetCookie( '_loginname' ); edtSenha.Text := UniApplication.Cookies.GetCookie( '_pwd' ); but the question is : where the default _loginname and _pwd came from ? Hello, UniMainModule -> OnBeforeLogin event ? procedure TUniMainModule.UniGUIMainModuleBeforeLogin(Sender: TObject; var Handled: Boolean); var S1, S2 : string; begin S1 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_loginname']; S2 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_pwd']; Handled := SameText(S1, 'demo') and SameText(S2, 'demo'); if Handled then LoggedUser := S1; end; Quote Link to comment Share on other sites More sharing options...
SergioFeitoza Posted March 10, 2021 Author Share Posted March 10, 2021 8 hours ago, Sherzod said: Hello, UniMainModule -> OnBeforeLogin event ? procedure TUniMainModule.UniGUIMainModuleBeforeLogin(Sender: TObject; var Handled: Boolean); var S1, S2 : string; begin S1 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_loginname']; S2 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_pwd']; Handled := SameText(S1, 'demo') and SameText(S2, 'demo'); if Handled then LoggedUser := S1; end; Thank you very much Sherzod I understood the idea Actually this phase is in my code exactly as you wrote with the words"demo" Question: Should I write instead of "demo" something like ? S1 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_loginname']; S2 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_pwd']; Handled := SameText(S1, 'myDEFAULTLOGIN') and SameText(S2, 'myDEFAULTPASSWORD'); Or leave the two spaces blank ? Quote Link to comment Share on other sites More sharing options...
SergioFeitoza Posted March 10, 2021 Author Share Posted March 10, 2021 12 hours ago, Sherzod said: Hello, UniMainModule -> OnBeforeLogin event ? procedure TUniMainModule.UniGUIMainModuleBeforeLogin(Sender: TObject; var Handled: Boolean); var S1, S2 : string; begin S1 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_loginname']; S2 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_pwd']; Handled := SameText(S1, 'demo') and SameText(S2, 'demo'); if Handled then LoggedUser := S1; end; Hi Sherzod, thank you in advance for the frequent help Now I went through the demo COOKIES and understood that what is missing to me is the concept of Cookies. I think that I understood something with the demo. When I clicked the button GET ALL COOKIES I saw (see figure) that sergio and 123 (the default username and password) are there. So, it seems that in some moment of the past I created this and remained there. I understood also that we can assign a expire date to the cookie. Question 1: How can I delete that cookie sergio 123 ? Question 2: about TUniGUIApplication Properties: (looking to TUniGUIApplication Properties ) Is there a demo to enable me to understand how to assign the application “parameters” property ? Quote Link to comment Share on other sites More sharing options...
SergioFeitoza Posted March 10, 2021 Author Share Posted March 10, 2021 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 10, 2021 Share Posted March 10, 2021 15 minutes ago, SergioFeitoza said: Question 1: How can I delete that cookie sergio 123 ? You can also specify a past date to remove. Quote Link to comment Share on other sites More sharing options...
SergioFeitoza Posted March 10, 2021 Author Share Posted March 10, 2021 Just to close: I found TUniGUIApplication.Parameters Property Quote Link to comment Share on other sites More sharing options...
SergioFeitoza Posted March 10, 2021 Author Share Posted March 10, 2021 2 hours ago, Sherzod said: You can also specify a past date to remove. Sherzod Thanks and resolved 1 Quote Link to comment Share on other sites More sharing options...
SergioFeitoza Posted March 10, 2021 Author Share Posted March 10, 2021 Suggestion to ADD A BUTTON IN THE DEMO COOKIES procedure TLoginForm.DeleteAllCookiesClick(Sender: TObject); var I : Integer; begin if UniApplication.Cookies.Count > 0 then for I := 0 to UniApplication.Cookies.Count - 1 do UniApplication.Cookies.SetCookie(UniApplication.Cookies[I],'',Date-1); end; Quote Link to comment Share on other sites More sharing options...
SergioFeitoza Posted March 10, 2021 Author Share Posted March 10, 2021 Just to Register, to facilitate to whom need here is the final solution (the last part of this post) afterrenfer Quote Link to comment Share on other sites More sharing options...
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.