Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1853
  • Last Modified:

Perl - problem with sleep();

I have a script and I want to add login sessions to it but I don't want to use cookies. I have already programmed a way to do this but the problem I am having is as follows.

When the user logs in 2 popup windows are generated via javascript.

The first is the main script that runs the program.

The second is the session script.

The session script is simple as it writes a 1 to a file, sleep(seconds go here*more seconds); then wakes up and writes a 0 to the file to be read by the main program.

The problem is: the first time the program runs, it works great. If I try and re-login though, the browser (IE) hangs till the session script wakes up and writes a 0 to the file...   if I close all browser windows it will work fine again...   any ideas would be much appreciated. I would post code, but there's just too much...

Thanks in advance for any help...
0
dr34m3rs
Asked:
dr34m3rs
  • 7
  • 2
  • 2
  • +2
1 Solution
 
ahoffmannCommented:
.. and what has it to do with perl?
0
 
ozoCommented:
What do you want to happen when you re-login?
What is the purpose of writing 1 and 0 to a file?
0
 
dr34m3rsAuthor Commented:
ahoffmann: perl uses the sleep(); function. Javascript is only the launcher for my perl scripts...

ozo: I want to be able to have the browsers not hang till script 3 (with the sleep(); function) is finished running...   the first time I run the scripts they all work just fine, the second time they hang till the sleep(); function is finished.

here is the code I use sleep(); with:

open(OUTF, ">$expire_file");       ### <- write to the expire_file so main script knows their session hasn't

### expired

print OUTF "1";
close(OUTF);

sleep(60*60);            ### <- allows login to expire after one hour

open(OUTF, ">$expire_file");     ### <- write to expire_flie so main script knows the session is expired and

### they need to relog

print OUTF "0";
close(OUTF);


The sleep function is the problem. I have to be able to break communication between the popup and the final script as it seems just closing the popup window doesn't do the trick...    but again, this only happens the second time around...

Thanks for any help. I am upping the points...
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
dr34m3rsAuthor Commented:
My the way, I have already tried close STDOUT;
0
 
ozoCommented:
How about using a different $expire_file for each session?
0
 
ahoffmannCommented:
sleep() does what you told it to do: sleeping one hour
Sounds like you need to rethink about what you want to archive: write to file, or sleeping an hour.
0
 
dr34m3rsAuthor Commented:
ozo: that's a good idea. I will try that and see how that works. I will get back to you on it. :)
0
 
jmcgOwnerCommented:
You didn't mention your flavor of web server. In past questions here, we've seen cases where closing stdout is sufficient to close out the connection on Apache/Linux but not for Windows/IIS.

You can have sessions without cookies by making a session key a part of the URLs used for all new visits by the user clicking a link or a submit button. Rewriting the URLs would mean using Dynamic HTML for everything, which may be too big a change if you're not already dynamic.

How is a user associated with the name of $expire_file?

Would it not be sufficient to write the expiration time in the file when you currently write a 1? Whatever checks for 1 or 0 currently could just check to see if the time _now_ is earlier or later than the expiration time.





0
 
dr34m3rsAuthor Commented:
I have solved the problem myself. Basically I just had to call the script that writes to the $expire_file via an image.

Thank you though for all the info. :)

At this point, I have no idea where to put the points.
0
 
jmcgOwnerCommented:
You can ask in Community Support (that's the "CS" button on the menu bar) to have your points refunded and this question deleted. Or you can close this question yourself by awarding points to one or more of the experts who offered help.
0
 
dr34m3rsAuthor Commented:
Ok thank you jmcg. :)

Have a nice day...
0
 
dr34m3rsAuthor Commented:
Actually no one was able to answer my question, so they get a C...    I appreciate their help, but they weren't able to solve the problem and I don't feel I should have to award any grade...   thanks. ;)
0
 
RomModCommented:
At your discretion, dr34m3rs. However, in the interest of fair play, should any participants object, the question will have to be reviewed.

I'm glad you arrived at a solution nonetheless.

RomMod
Community Support Moderator
0
 
dr34m3rsAuthor Commented:
Thank you RomMod...   Have a great T-Day if you guys are in the US....

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 7
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now