Solved

Perl - problem with sleep();

Posted on 2003-11-21
15
1,848 Views
Last Modified: 2012-06-27
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
Comment
Question by:dr34m3rs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 2
  • 2
  • +2
15 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 9800067
.. and what has it to do with perl?
0
 
LVL 84

Expert Comment

by:ozo
ID: 9800995
What do you want to happen when you re-login?
What is the purpose of writing 1 and 0 to a file?
0
 
LVL 1

Author Comment

by:dr34m3rs
ID: 9802022
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!

 
LVL 1

Author Comment

by:dr34m3rs
ID: 9802023
My the way, I have already tried close STDOUT;
0
 
LVL 84

Expert Comment

by:ozo
ID: 9802061
How about using a different $expire_file for each session?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 9802231
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
 
LVL 1

Author Comment

by:dr34m3rs
ID: 9804596
ozo: that's a good idea. I will try that and see how that works. I will get back to you on it. :)
0
 
LVL 20

Expert Comment

by:jmcg
ID: 9808586
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
 
LVL 1

Accepted Solution

by:
dr34m3rs earned 0 total points
ID: 9816654
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
 
LVL 20

Expert Comment

by:jmcg
ID: 9817484
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
 
LVL 1

Author Comment

by:dr34m3rs
ID: 9823116
Ok thank you jmcg. :)

Have a nice day...
0
 
LVL 1

Author Comment

by:dr34m3rs
ID: 9829942
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
 

Expert Comment

by:RomMod
ID: 9829966
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
 
LVL 1

Author Comment

by:dr34m3rs
ID: 9829974
Thank you RomMod...   Have a great T-Day if you guys are in the US....

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question