Page 1 of 1
Cross-page variables
Posted: Thu Mar 20, 2008 1:24 pm
by hayson1991
Hi, I'm new to this forum.
Does anyone here know a way to share variables between concurrent (i.e. both running at the same time) pages in php?
I know that I can probably do this with sessions. But it's bad to have a session open all the time right?
I also know that MySQL can also be used, but that will be too many MySQL calls...
(This is for something similar to a chat program.)
Thanks.
Re: Cross-page variables
Posted: Thu Mar 20, 2008 11:33 pm
by yacahuma
cocurrent pages by the same user? If you want a chat use a database.
Re: Cross-page variables
Posted: Fri Mar 21, 2008 12:01 pm
by hayson1991
yacahuma wrote:cocurrent pages by the same user? If you want a chat use a database.
But isn't that too many calls to MySQL? or are you talking about another database system?
Re: Cross-page variables
Posted: Fri Mar 21, 2008 12:06 pm
by John Cartwright
Using mysql should be ok, it is a lot quicker than people think

Re: Cross-page variables
Posted: Fri Mar 21, 2008 1:13 pm
by hayson1991
Jcart wrote:Using mysql should be ok, it is a lot quicker than people think

Ok, I tried that, but I'm just afraid that it'll eventually call mysql too many times and get a max_connection error...
Re: Cross-page variables
Posted: Fri Mar 21, 2008 2:18 pm
by hayson1991
I've also been wondering if it is possible for one concurrent page to cause an action on another concurrent page.
i.e. if person A is loading a page and person B just submitted something, person A's page can, during load, add extra content to itself.
Re: Cross-page variables
Posted: Fri Mar 21, 2008 3:18 pm
by Christopher
It can, but you need to poll at some point. You might want to look into Ajax/Comet.
Re: Cross-page variables
Posted: Fri Mar 21, 2008 10:39 pm
by yacahuma
You are not going to get any connection max. Remember that PHP only connects to the database when is creating the html. After those milliseconds the connection is release.
Re: Cross-page variables
Posted: Sat Mar 22, 2008 11:51 am
by hayson1991
arborint wrote:It can, but you need to poll at some point. You might want to look into Ajax/Comet.
So, there's no way to do this without polling? I'm currently trying to replicate Comet, but I really don't want to poll continuously.
Re: Cross-page variables
Posted: Mon Mar 24, 2008 9:04 am
by John Cartwright
hayson1991 wrote:arborint wrote:It can, but you need to poll at some point. You might want to look into Ajax/Comet.
So, there's no way to do this without polling? I'm currently trying to replicate Comet, but I really don't want to poll continuously.
HTTP is stateless, therefore, you'll require polling to continuously update the page. I wouldn't worry about performance until it becomes an issue.
Re: Cross-page variables
Posted: Mon Mar 24, 2008 2:33 pm
by hayson1991
Jcart wrote:hayson1991 wrote:arborint wrote:It can, but you need to poll at some point. You might want to look into Ajax/Comet.
So, there's no way to do this without polling? I'm currently trying to replicate Comet, but I really don't want to poll continuously.
HTTP is stateless, therefore, you'll require polling to continuously update the page. I wouldn't worry about performance until it becomes an issue.
well, at the scale I'm making this for, performance will become an issue... do you have any suggestions? thanks.
(I want this to be an extensible project, so, I want as good of a performance as possible. Any extensions to use instead of MySQL would be appreciated...)