Solved

Perl - problem with sleep();

Posted on 2003-11-21
15
1,843 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
  • 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
 
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

705 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now