Cross-page variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hayson1991
Forum Newbie
Posts: 14
Joined: Thu Mar 20, 2008 1:19 pm

Cross-page variables

Post 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.
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: Cross-page variables

Post by yacahuma »

cocurrent pages by the same user? If you want a chat use a database.
hayson1991
Forum Newbie
Posts: 14
Joined: Thu Mar 20, 2008 1:19 pm

Re: Cross-page variables

Post 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?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Cross-page variables

Post by John Cartwright »

Using mysql should be ok, it is a lot quicker than people think ;)
hayson1991
Forum Newbie
Posts: 14
Joined: Thu Mar 20, 2008 1:19 pm

Re: Cross-page variables

Post 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...
hayson1991
Forum Newbie
Posts: 14
Joined: Thu Mar 20, 2008 1:19 pm

Re: Cross-page variables

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Cross-page variables

Post by Christopher »

It can, but you need to poll at some point. You might want to look into Ajax/Comet.
(#10850)
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: Cross-page variables

Post 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.
hayson1991
Forum Newbie
Posts: 14
Joined: Thu Mar 20, 2008 1:19 pm

Re: Cross-page variables

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Cross-page variables

Post 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.
hayson1991
Forum Newbie
Posts: 14
Joined: Thu Mar 20, 2008 1:19 pm

Re: Cross-page variables

Post 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...)
Post Reply