Buyocat Posted July 23, 2006 Share Posted July 23, 2006 I'm working on making my sessions customized and I've found something strange with the session_name function that I thought I'd ask the community about. I wanted to see how things worked so I made two pages, on the first I start a session and assign it an ID and name using session_id and session_name. On the second page I just print_r the $_REQUEST array to see how the sessions are being passed. The problem is that when I do that I see that there are two sessions. One which is PHPSESSID the other is the name I set and both have the ID that I set. Now I've checked to see that auto sessions are off -- they are -- so I'm a little confused as to why session_name is just making a duplicate and not replacing PHPSESSID. Does anyone know why this is happening or a work around? Quote Link to comment https://forums.phpfreaks.com/topic/15400-using-session_name/ Share on other sites More sharing options...
Buyocat Posted July 23, 2006 Author Share Posted July 23, 2006 EDIT Problem solved :) Quote Link to comment https://forums.phpfreaks.com/topic/15400-using-session_name/#findComment-62450 Share on other sites More sharing options...
wildteen88 Posted July 23, 2006 Share Posted July 23, 2006 When ever you define a custom session id or name for a session you will have define session_id and session_name before the use of session_start in order for PHP to load up your session. If you dont want to define session_id('11'); and session_name('test session'); every time you want to access the session, either create a function eg:[code]function my_session_start($id, $name){ session_id($id); session_name($name); session_start();}[/code]Then when you want to start your session do this:[code]<?php// get session functioninclude 'session.php';// start sessionmy_session_start('11', 'test_sess');// rest of code[/code]That way you called three function with just one function.Or create your own [url=http://uk2.php.net/manual/en/function.session-set-save-handler.php]session handler[/url] Quote Link to comment https://forums.phpfreaks.com/topic/15400-using-session_name/#findComment-62454 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.