We have to login to a http page so that I can surf the net. But, that login page also requires me to keep that page open which is very irritating. The page have javascript that checks if the page is loaded every 180 seconds, it its not loaded, I am logged out.

I want to simulate a browser using a programming language like python or using curl or anything so that I am not forced to keep the webpage open.
How can I do that? I have uploaded the source code of the webpages of login_page, javascript and ajax scripts used.

I am not actually sure as to how it is being accomplished so I dont know how to simulate it. Please note the sendLiveRequest function in javascipt script.

AJAX Script -> http://sprunge.us/gMBR?js
JAVASCRIPT -> http://sprunge.us/gPeL?js
mainpage.html -> http://sprunge.us/MFLM?html

I work on linux so please provide solutions regarding linux platform or atleast give idea of whats actually being used here and how should I proceed.

Recommended Answers

All 5 Replies

Maybe use PHP and if you login set a Cookie to the user, with the username and give the Cookie a time of 180seconds till it will be romoved from the browser. Everytime when the user refreshes the page the cookie's time will reseted to 180seconds. if the cookie is removed and the user reloads the page, he will be logged out.

Maybe use PHP and if you login set a Cookie to the user, with the username and give the Cookie a time of 180seconds till it will be romoved from the browser. Everytime when the user refreshes the page the cookie's time will reseted to 180seconds. if the cookie is removed and the user reloads the page, he will be logged out.

Does PHP support javascript? Bcos its being checked using javascript and ajax. I am no expert in this field but I think that setting the cookie wont help.

setting the cookie will help, and PHP is a server-sided script, its actually HTML with additional codes... javascript is included like in HTML. just try like this:
beim login:

<?php
setcookie('cookie',$username,180); //Names the Cookie "cookie" and sets the value to the variable $username
?>

and include in the pages:

<?php if(isset($_COOKIE['cookie'])) {  setcookie('cookie','$_COOKIE['cookie'],180); ?>
...Content for logged Users
<?php } else { ?>
...Content for guests
<?php } ?>

learing php: http://www.w3schools.com/php/php_intro.asp

@Agarsia


I am the client here, not the server side. What you told me is an alternative way of accomplishing which is being accomplished already at the server side.
I am the client here and want to somehow simulate that the login page is opened in browser and when the "see if LIVE" request comes, it should be satisfied like its done when I actually open the webpage in the browser.

yes, but the cookie is saved in the clients browser, so this part is client-sided, and the time till the cookie is removed is also running on the clients' pc, only the setting of the cookie and the if-function running serer-sided, so if the cookie is removed on the clients pc, the if-function returns the user to the guests-page to relogin.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.