Sharing session info

Is there a way info can be shared between sessions with different users? For example, an admin logs in to the main page and this causes a content change. Then when each user logs in, I would like them to see the new content. I suspect there is a way, but I have no idea how to do this.

Any help is appreciated!

I think you’re misunderstanding the term sessions and what they do.

HTTP (or the internet) is stateless, IE: it doesn’t remember anything from page to page.
To combat this we use various methods, cookies, sessions, databases etc.

If I log in to your website, the session that is created is for my browser only - you will get a different session - the same, but different as it only exists in your browser.

When an admin logs in and changes content, i can see that content next time the page is refreshed.
If you want to put a notification (like facebook) then you need to ‘push’ that to the server.
Have a read of this wiki which explains far better than i can what pushing data requires.

Hope that helps,
Red :wink:

Thanks Red. Poor choice of words on my part. Yeah, I get the sessions ok.
A better example of what I need to do would be an instant messenger application.
What technique is used in those programs?

pretty much the same, user enters comment, comment is pushed to the server, rinse and repeat.

You could do this with PHP if you threw a little javascript (jquery) in the mix.
Just a matter of a php script reading the database and echoing the result which will be picked up by a jquery script and placed in a div etc.

Thanks. I was just reading about jQuery when you posted. Looks like it might be a good way to do what I need.

It’s probably the way i would go and if you don’t know jquery you’ll be pleasantly surprised at how easy it is to learn/understand. Pretty nifty little tool to add to your arsenal :wink:

Just dont do what this guy tried last week with a instant messenger application and use the cookie to store the WHOLE CHAT…if you do only use it as an id for a database reference haha.

Also… Hi Red!

Thanks Lewis. I’ll certainly try not to do anything like that! :wink:
As each user logs in I’m storing them in a database with a primary key id so your idea for the cookie would work fine for me.

Id probs recommend generating a hashed key… which from that you can match that from the database to the cookie key. Means people wont be able to easily change the cooke key to switch across user chats.

Sponsor our Newsletter | Privacy Policy | Terms of Service