How to run server script continuously and send the update da

Links for php scripts

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 22
Joined: Wed May 02, 2012 5:27 am

Wed Aug 29, 2012 1:51 am

Hello Everyone,

I am working on site creation and I am newbie with this work. I have used php for creating my site.I want to create server script that run on my machine continuously and send the updated data to the client who want that data. I have created two sample code one is Server.php and another is Client.php.

$_SESSION['Argument'] = 10;
while(1) {
print "Updated data in Server Script ".$_SESSION['Argument'];
$_SESSION['Argument'] += 20;

print "Updated data in Client Script ".$_SESSION['Argument'] ;

I want to run the Serever.php without using browser and as a background process. When I will run Client.php from browser, I want the updated data every time.Is it possible ?

Because, I was run Server.php through command prompt it run but, when I run Client.php script through browser then it return error "Notice: Undefined index: Argument in Client.php". I was searched about this problem I was found that due to different session_id Client.php script didn't identify the session variable of Server.php.

After that I was run my server script by usiong "wget http://localhost/Server.php" through command line because I thought that apache maintian the session variable or session_id. But still I got same notice. I was never used cron method because it run script periodically not continuously.

Is there is any way to solve my problem please help me. I was suffered from last 4 days.

Thanks and Regard,
Antrikssh... :)

New php-forum User
New php-forum User
Posts: 6
Joined: Wed Sep 05, 2012 5:38 am

Fri Sep 07, 2012 10:17 am

At first you have to understand the principle of the php sessions works, it like a cookie, additional a files in your server which store session data. That session_id stored in your browser like a cookie, when you try to get this session data from another browser or terminal you dont get it, becabrowseruse session_id store in another browser, or terminal.

Post Reply