tinwatchman Posted September 2, 2009 Share Posted September 2, 2009 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 More sharing options...
justsomeguy Posted September 2, 2009 Share Posted September 2, 2009 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 More sharing options...
tinwatchman Posted September 2, 2009 Author Share Posted September 2, 2009 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 More sharing options...
justsomeguy Posted September 2, 2009 Share Posted September 2, 2009 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. Link to comment Share on other sites More sharing options...
tinwatchman Posted September 2, 2009 Author Share Posted September 2, 2009 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.That did it. Fantastic. Thanks for the help. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.