Re: session expire timeout

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hadi wrote:

> I have session timeout  set to 1 with while loop, it well keep looping until
> session expire, then it well run my script "
> file_put_contents('/tmp/phptest1234.txt', 'test');".
> Also I have javascript to keep pulling the script to keep it alive every
> interval time. If I close javascript page no more pulling the script then it
> well timeout and run my script " file_put_contents('/tmp/phptest1234.txt',
> 'test');" 
> 
> 
> When I open javascript page it well call my php script and  execute it along
> with " file_put_contents('/tmp/phptest1234.txt', 'test');".
> 
> What I want here when I open javascript page it should keep pulling my php
> script. And if I close the page timeout well happen to my php script and
> execute my script " file_put_contents('/tmp/phptest1234.txt', 'test');" 
> 
> But this doesn't seems to work. How to accomplish this senior. Can somebody
> give help here please.

I hardly can make any sense of your description, but the following
comments might help you a bit.

> Php code
> 
> <?php
> session_start();
> ?>
> 
> <?php
> 
> $_SESSION['timeout'] = time();
> 
> $st = $_SESSION['timeout'] + 1;
> 
> while(time() <  $st)
> 
> {
> 
> echo "$st\n";
> 
> 
> }

Instead of the while loop, you can use sleep
(<http://www.php.net/manual/en/function.sleep.php>).

> file_put_contents('/tmp/phptest1234.txt', 'test');
> 
> 
> 
> 
> 
> ?>
> 
> Javascript code
> 
> <script type="text/javascript" src="jquery-1.11.1.js"></script>
> 
> 
> 
> <script type="text/javascript" >
> 
> $(function(){
>     // set interval for 5 minutes
>     setInterval(function(){
>             $.ajax({url: "test7.php"
> 
>             });
>     }, 10000);

10000 doesn't mean 5 minutes, but 10,000 milliseconds (i.e. 10 seconds).
 This interval, however, is only an approximation by the nature of
JavaScript's event loop.

> });
> 
> </script>

-- 
Christoph M. Becker




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux