niranjan81 Posted May 9, 2010 Share Posted May 9, 2010 When ther server is configured to use cookies to store session ids, is there any way by which a developer can assign a manual session_id() to the second level / page in the users flow? Since, unlike session_regenerate_id() the session_id does not set the cookie all by itself. And in the second page, once we do session_start() to reach out to session data we can not repeat session_start. Therefore, in my understanding what we Can Not do is: <?php session_start(); <----some code here----> session_id(); session_start(); <---rest of the code---> ?> Since, the second session_start() in the above example is simply ignored. Nor Can we do it right in the beginning like: <?php session_id('my_session_id'); session_start(); <---rest of the code---> ?> Since, when we do that the cookie is set to the new session_id which is 'my_session_id' and the old data is then completely Unreachable / Lost The only way I can figure out is: In the first page do session_id('my_session_id') at the end of the page like <?php <---rest of the code---> session_id('my_session_id'); ?> and then in the second page do <?php session_id('my_session_id'); session_start(); <---rest of the code---> ?> Is this the right way of doing it ? Or is there is a better way to accomplish this ? Thanks. Link to comment https://forums.phpfreaks.com/topic/201137-how-to-do-session_idmy_session_id-correctly/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.