Results 1 to 21 of 21

Thread: Login problem (cookies)

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2014
    Posts
    38

    Login problem (cookies)

    in finally i maked this code to work but my problem is cause when i'm login with id & password on textbox on site remember logged on and when i want again to run program to login i need to go on site to press log out

    Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    If WebBrowser1.DocumentText.Contains("Logout") Then
    WebBrowser1.Document.Forms("Logout").All("Logout").InvokeMember("click")
    WebBrowser1.Navigate("http://royal.3xforum.ro/login.php")
    End If
    Delay(1)
    WebBrowser1.Document.All("req_username").SetAttribute("value", TextBox1.Text)
    WebBrowser1.Document.All("req_password").SetAttribute("value", TextBox2.Text)
    WebBrowser1.Document.Forms("login").All("login").InvokeMember("click")
    Delay(1)

    If WebBrowser1.DocumentText.Contains("Logare reusita.") Then
    Form2.Show()
    Me.Hide()

    Else
    MsgBox("Parola / ID , Invalid")
    End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub
    Private Sub Delay(ByVal dblSecs As Double)
    Const OneSec As Double = 1.0# / (1440.0# * 60.0#)
    Dim dblWaitTil As Date
    Now.AddSeconds(OneSec)
    dblWaitTil = Now.AddSeconds(OneSec).AddSeconds(dblSecs)
    Do Until Now > dblWaitTil
    Application.DoEvents()
    Loop

    End Sub


    End Class

  2. #2

    Thread Starter
    Member
    Join Date
    Apr 2014
    Posts
    38

    Re: Login problem (cookies)

    or when i press login and i'm logged auto. logout

  3. #3
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,187

    Re: Login problem (cookies)

    Dat CPU.

    Code:
    Do Until Now > dblWaitTil
    Application.DoEvents()
    Loop
    You should not be doing this. Instead handle the Document Completed event on the web browser control and check the url when the event occurs (maybe along with an Enum or Parameter) to determine what you should do next.

  4. #4
    Member vbProsecutor's Avatar
    Join Date
    Jun 2014
    Location
    Canada (I'm sorry)
    Posts
    60

    Re: Login problem (cookies)

    I guess you have a different page for the logout and login. When you're in the login page, it doesn't see the logout button, and vice-versa. So at the form load, you should navigate to your logout page. Sorry if that's incorrect, that's what I'm understanding. Bun noroc

  5. #5

    Thread Starter
    Member
    Join Date
    Apr 2014
    Posts
    38

    Re: Login problem (cookies)

    Quote Originally Posted by vbProsecutor View Post
    I guess you have a different page for the logout and login. When you're in the login page, it doesn't see the logout button, and vice-versa. So at the form load, you should navigate to your logout page. Sorry if that's incorrect, that's what I'm understanding. Bun noroc
    Noroc si tie dar nu la asta ma refeream ) esti ro?
    on form1 i have just 1 button and 2 textboxts and webrowser is hide soo.. i can't se logout button on site .. i want auto logout after when i press log in button on form if is possible , because when i want to run again my program i can't login because is logged..

  6. #6
    Member vbProsecutor's Avatar
    Join Date
    Jun 2014
    Location
    Canada (I'm sorry)
    Posts
    60

    Re: Login problem (cookies)

    Da, sunt roman mutat in Canada . So did you find your error? I think I did. I think WebBrowser1.DocumentText doesn't contain anything because it hasn't loaded yet. So before doing your if statement, you could add:

    Code:
    Do Until WebBrowser1.ReadyState = WebBrowserReadyState.Complete
         Application.DoEvents()
    Loop
    Sorry for not responding fast, hope it helps.

  7. #7
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,187

    Re: Login problem (cookies)

    Quote Originally Posted by vbProsecutor View Post
    Da, sunt roman mutat in Canada . So did you find your error? I think I did. I think WebBrowser1.DocumentText doesn't contain anything because it hasn't loaded yet. So before doing your if statement, you could add:

    Code:
    Do Until WebBrowser1.ReadyState = WebBrowserReadyState.Complete
         Application.DoEvents()
    Loop
    Sorry for not responding fast, hope it helps.
    You probably should not encourage this habit. He should really be waiting for the document completed event to fire, then check the document text. If the page text still isnt loaded at that point (some ajax sort of thing) the document complete should enable a timer to constantly check for X amount of seconds until documentText has value.

  8. #8
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: Login problem (cookies)

    I have already told you in your thread yesterday to read MSDN documentcompleted. You choose to ignore these instructions.

  9. #9
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: Login problem (cookies)

    Quote Originally Posted by jayinthe813 View Post
    You probably should not encourage this habit. He should really be waiting for the document completed event to fire, then check the document text. If the page text still isnt loaded at that point (some ajax sort of thing) the document complete should enable a timer to constantly check for X amount of seconds until documentText has value.
    No timer should ever be needed or even considered being used.

  10. #10
    Member vbProsecutor's Avatar
    Join Date
    Jun 2014
    Location
    Canada (I'm sorry)
    Posts
    60

    Re: Login problem (cookies)

    Quote Originally Posted by jayinthe813 View Post
    You probably should not encourage this habit. He should really be waiting for the document completed event to fire, then check the document text. If the page text still isnt loaded at that point (some ajax sort of thing) the document complete should enable a timer to constantly check for X amount of seconds until documentText has value.
    That's true, I feel silly for not having thought about it

  11. #11

  12. #12
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,187

    Re: Login problem (cookies)

    Quote Originally Posted by ident View Post
    No timer should ever be needed or even considered being used.
    What if the document completed event fires but the document text isn't finished loading? Like its pulling from a database?

  13. #13

  14. #14
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,187

    Re: Login problem (cookies)

    Quote Originally Posted by ident View Post
    Check the browser is not busy.
    I suppose that may be a general rule, but I have seen some websites where ReadyState is indicated complete and also fire Document Completed, but still need additional time to load data from a database. I do not know how to handle this scenario other than to check for the values. The database load times vary, so its not something that can be readily timed. What would you do in that instance?

    I suppose this will probably not happen often, but it may serve the OP to know now what he should do in the future.
    Last edited by jayinthe813; Aug 9th, 2014 at 07:07 PM.

  15. #15
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: Login problem (cookies)

    Document completed fires multiple times. As i already said check is.not busy

  16. #16
    PowerPoster ThEiMp's Avatar
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,899

    Re: Login problem (cookies)

    When doing the checking you then have to then check the Browser and then the App, finally when the check has successfully been counted as being finished then you can then pass onto the next marker in the program. That is what you want, right???

    So it goes like this:
    1. Check the Browser has finished
    2. If the Browser isn't finished then go back to the 1. marker
    3. If the Browser has finished the initializing of the program then goto 4. marker
    4. Do the work here and execute the several lines of source code, here...
    5. End the App, here
    I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...

    |Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Event's Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Bar | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University |

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

  17. #17
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,187

    Re: Login problem (cookies)

    Quote Originally Posted by ident View Post
    Document completed fires multiple times. As i already said check is.not busy
    Not to make you smash your head any further into your desk, but I had the experience on an intranet system where 1 Document Completed event fires (Expected), and the web browser indicates it is not busy (Expected), and it still does not have data loaded because somehow the web page is pulling the data via javascript or something.

  18. #18
    PowerPoster ThEiMp's Avatar
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,899

    Re: Login problem (cookies)

    can I know what kind of data it is, something like a graphic or something like that. cause if it is pulling a graphic, that can easily be fixed using caching processes and then if it is pulling variables then that is a whole different manner of speaking in terms of source code. If that happens then we have to look at the idea of making temp files, or such things on the local hard disk drive, which is something that isn't the best option since that the main idea is to keep data from a VB.NET or Visual Basic App that appears on the Internet Cloud or not, then that would be the worse case scenario to look at, since that the data is then left on the system. By all means look at removing the temp files from the system when the browser windows is closed, in the current computer session...
    I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...

    |Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Event's Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Bar | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University |

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

  19. #19
    PowerPoster ThEiMp's Avatar
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,899

    Re: Login problem (cookies)

    [ACTION]
    -- knasshing teeth and mashing head into desk, right about now...
    [/ACTION]
    I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...

    |Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Event's Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Bar | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University |

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

  20. #20
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,187

    Re: Login problem (cookies)

    Quote Originally Posted by ThEiMp View Post
    can I know what kind of data it is, something like a graphic or something like that. cause if it is pulling a graphic, that can easily be fixed using caching processes and then if it is pulling variables then that is a whole different manner of speaking in terms of source code. If that happens then we have to look at the idea of making temp files, or such things on the local hard disk drive, which is something that isn't the best option since that the main idea is to keep data from a VB.NET or Visual Basic App that appears on the Internet Cloud or not, then that would be the worse case scenario to look at, since that the data is then left on the system. By all means look at removing the temp files from the system when the browser windows is closed, in the current computer session...
    If you are referring to me, I am not the OP. I am merely stating some situations that have arisen in my experience where the Document Completed event and Browser ReadyState is indicating that the page is loaded, but in reality, data is still missing. For example, using .GetElementById method, I pull empty strings, which populate actual data in ~5 or so seconds after these events/indicators occur. If I use a timer to check the element, I can access the data once it is populated.

    The OP probably will not experience this, but I like to keep things in the back of my mind because who knows when things will go awry/not as you expect and you need a recourse of action.

  21. #21
    PowerPoster ThEiMp's Avatar
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,899

    Re: Login problem (cookies)

    I have the very same problem with Consoles such as this one. When you login then .ZOrder a Command Button, which is called: Logout. Then when you logout then .ZOrder a Command Button, which is called: Login. And then the Default is setup as the Command Button, which is called: Login is set to .Zorder 0
    I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...

    |Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Event's Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Bar | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University |

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width