Jump to content

Possible To Share Data Between Sessions?


tinwatchman
 Share

Recommended Posts

So here's an interesting question for everyone. As opposed to the principles mentioned in the PHP guide here - let's say that I actually *wanted* to allow other users to monitor a session that's *currently in progress*, in real time. (Before you ask, I've already tried sharing the SID. But the server doesn't seem to want to allow it - it just grants the other user a new session ID.) I know that I could just write everything to a database and share the info *that way*, but I'm worried that it won't be fast enough. What do you think? Any way to go about it that I'm missing?Thanks!

Link to comment
Share on other sites

Storing sessions in a database wouldn't be that slow, but you would still need to assign a session ID to another user.I'm curious about how you're doing that though. How do you know which existing session ID to assign to a user? It should work though, if you set a new session ID before using session_start then it should use that session ID for the user. If the user already has a session though it's not going to work on the same request, you would need to refresh the page to access the new session.

Link to comment
Share on other sites

Storing sessions in a database wouldn't be that slow, but you would still need to assign a session ID to another user.I'm curious about how you're doing that though. How do you know which existing session ID to assign to a user? It should work though, if you set a new session ID before using session_start then it should use that session ID for the user. If the user already has a session though it's not going to work on the same request, you would need to refresh the page to access the new session.
I've written a web app that stores most of its data on the server-side in $_SESSION. The idea is, I want the user to be able to send a link to other users that will allow them to monitor his/her session data in real time, as he or she modifies it. In this case, the link would contain the session ID. I've tried it in testing myself by generating the information in one browser and trying to monitor it in another - but the server seems to grant the second browser a new session ID, no matter what I do or how I pass the SID. My only guess at the moment is that the server won't allow anyone access to that session while it's still active in the first browser. Does anyone have any other ideas I could try?
Link to comment
Share on other sites

PHP doesn't work that way, I haven't heard of it tying a session to a specific IP or whatever. If the browser sends a session cookie, PHP uses that ID for the session. It sounds like you're not setting the new ID soon enough. You can also just use setcookie to set the session cookie yourself explicitly, and then refresh the page.Keep in mind you have to refresh the page after setting a new ID.

Edited by justsomeguy
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...