Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I usually have to visit a website:

that contains the following line in it's HTML code:

SESSION_TIMEOUT = 1800;//in seconds.

I need to change this string to ex.:

SESSION_TIMEOUT = 1800000;//in seconds.

Greasmonkey can do this. But how? I kept googling for hours, but the original line is untouched... Can someone help me?

share|improve this question
Is SESSION_TIMEOUT a global JavaScript variable? – cmorse Dec 5 '11 at 0:12
@cmorse - I think its responsible for the webpage to timeout/log out the logged in user. – LanceBaynes Dec 5 '11 at 0:22
@LanceBaynes - I was thinking that if it is just a JavaScript variable then you could just set it to the desired value with a greasemonkey script. – cmorse Dec 5 '11 at 0:26
@LanceBaynes: You should look for a browser-specific solution to access the original window context, this can differ between browsers. It could be so that the session timeout is somehow forced on you (perhaps by a timer or AJAX calls), in which case you aren't able to change it. Also note that changing a client-side timeout won't impose a server-side timeout change... – Tom Wijsman Jan 8 '12 at 19:01
Why don't you change the session time out in Maximo application? If you use LDAP, there is also an LDAP token that expires that is separate from the session time out if you use WebSphere application server. – sunk818 Mar 31 at 19:22

3 Answers 3

// ==UserScript==
// @name          Script Name Here
// @namespace
// @description   An Greasemonkey script that changes the session timeout value
// @include
// ==/UserScript==
window.SESSION_TIMEOUT = 1800000;


share|improve this answer
this one doesn't work too :\ – LanceBaynes Jan 7 '12 at 15:05
can you provide more details? how have you checked that it doesn't work - have you used, for example, javascript console to check if the variable was changed or not? is there an error message? – eis Jan 7 '12 at 19:57
The version with unsafeWindow should work. Mine does not seem to, but cannot comment on that one, so commented here. But please add some more details as to why that one does not work. – eis Jan 7 '12 at 20:05
@eis: window doesn't give full access, unsafeWindowis browser-dependent. – Tom Wijsman Jan 8 '12 at 2:14

You'll want to use unsafeWindow, which, as the name infers, is not the most secure method -- but if all you are doing is changing the value of a page based variable, there's no risk involved.

// ==UserScript==
// @name          Script Name Here
// @namespace
// @description   An Greasemonkey script that changes the session timeout value
// @include
// ==/UserScript==

unsafeWindow.SESSION_TIMEOUT = 1800000;

If you just use window.SESSION_TIMEOUT, you more than likely will not be accessing the correct scope, and your SESSION_TIMEOUT variable would go unmodified, and a new one created inside another context / scope.

share|improve this answer
it doesn't work, sorry :\ – LanceBaynes Jan 7 '12 at 15:05
@lawrencealan: unsafeWindow is browser-dependent. – Tom Wijsman Jan 8 '12 at 2:14
@TomWijsman Where do you see that unsafeWindow is browser dependent? It was my understanding that it is implemented in the GreaseMonkey plugin itself... – lawrencealan Jan 9 '12 at 16:50
@LanceBaynes try using a timer, I have a feeling that the value is being overwritten due to the order of inclusion, but I could be wrong. – lawrencealan Jan 9 '12 at 16:53
@TomWijsman Greasemonkey is officially only an extension for Mozilla Firefox, other browsers are not guaranteed to work. – lawrencealan Jan 9 '12 at 21:05

Good old

location.href="javascript:(function(){ window.SESSION_TIMEOUT = 1800000; })()"

trick should work.

share|improve this answer
Can I ask how to implement this? to a userscript?? – LanceBaynes Jan 8 '12 at 6:22
I tried it in a userscript. it doesn't work either :D:D maybe the Maximo tool is based on something that overrides this's a mistical thing for me... – LanceBaynes Jan 8 '12 at 6:33
@LanceBaynes: Although my code should work, here is a Q&A explaining this trick and another trick. I've used the script trick before as well as well as that location trick and the one I mentioned. If none of these work, you simply can't do anything with that value. It might even be so that that value is solely used to start a timer and later not used anymore in any way... – Tom Wijsman Jan 9 '12 at 20:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.