Sign in to follow this  
Followers 0
Vakari

Keeping website in IE from timing out

2 posts in this topic

#1 ·  Posted (edited)

I'm trying to find a way to keep a session on a website from timing out, and so far have been unsuccessful.

Lets say that I'm logging in to Website.com and it will end your session after 20 minutes of inactivity. This is what I've tried so far:

Func KeepAlive()
    If IsObj($oIE) Then
        _IEAction($oIE, "refresh")
    Else
        $oIE = _IECreate("http://www.website.com", 0, 0, 0, 0)
    EndIf
EndFunc

When the user is on website.com, this function will be called. It creates a hidden window to the site and refreshes it. We'll assume KeepAlive() is called every 5 minutes or so only if the user is currently logged onto website.com (Which is handled successfully elsewhere in the script). This was my first feeble attempt, and I didn't attempt to troubleshoot it at all when it failed, I went on to another attempt.

AdlibEnable("KeepAlive", 5000)

While 1
    If WinExists("Website.com") Then
        $SiteActive = True
    Else
        $SiteActive = False
        $RefreshDelay = 300001
    EndIf
WEnd

Func KeepAlive()
    If Not $SiteActive Then
        $LastSite = ""
        Return
    EndIf
    If TimerDiff($RefreshDelay) < 300000 Then Return
    $oIE = _IEAttach("http://www.website.com", "URL")
    $CurrentSite = _IEBodyReadHTML($oIE)
    If $CurrentSite = $LastSite Then
        ConsoleWrite("Page is the same, refreshing" & @CR)
        _IEAction($oIE, "refresh")
    Else
        ConsoleWrite("Page changed" & @CR)
    EndIf
    $oIE = ""
    $LastSite = $CurrentSite
    $RefreshDelay = TimerInit()
EndFunc

This one was intended to refresh the page every 5 minutes if the page had not changed, meaning the user was not actively using it. It technically worked and refreshed the page, but did not keep the site alive. It would still time out after 20 minutes.

I guess 'refresh' just isn't enough when trying to keep a site alive. The only alternative I can think of is to navigate away from the page then navigate back. Unfortunately the site is 99% java and I haven't yet figured out how to interact with java buttons/forms and whatnot. I've seen a few people give very vague examples on how to attempt it, but none of them are 'working' examples.

I'm sure there are other programs out there that will handle this for me, but I thought I'd try to write one on my own and include it in another script I've created, which, surprisingly, works quite well :D

I have a good feeling that I'm going about this all wrong, or there is some built-in function that will take care of it, but I just can't see it at the moment.

Any tips would be appreciated. Thank you for your time.

Edited by Vakari

Share this post


Link to post
Share on other sites



What it takes to keep your session "alive" depends wholy on the server-side logic, so I can't really guess what is required.

One suggestion is that a refresh doesn't necessarily do all that you expect on the server side if it is determined that there have not in fact been any changes to the page (and you end up refreshing from cache). One trick to work around that is to add something to the URL to make it unique without really changing the page request... in particular:

_IENavigate($oIE, "http://www.website.com?foo=" & Random(0, 999999, 1))

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0