faraz Posted December 21, 2006 Share Posted December 21, 2006 hi,i m new to PHP with a .net framework background, i want to use session in my app., is placed session_start() at the top of the page. in a function aa i used $_SESSION['id']='1', and in another function bb, i want to retrive session value by using $id = $_SESSION['id'], but it return nothing. any one know to access the session value??ThanksFaraz Link to comment https://forums.phpfreaks.com/topic/31457-solved-accessing-session-values/ Share on other sites More sharing options...
trq Posted December 21, 2006 Share Posted December 21, 2006 That is exactly how it is done. Just make sure session_start() is caleed at the top of any page you wish to use sessions with. Link to comment https://forums.phpfreaks.com/topic/31457-solved-accessing-session-values/#findComment-145716 Share on other sites More sharing options...
faraz Posted December 21, 2006 Author Share Posted December 21, 2006 thanks for your reply.i slightly changed the code, i used <?php ?> instead of <? ?> at the top, but now it is throwing warning: Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at D:\wamp\www\hr\Test1.php:7)is there any difference between the tags? bcoz i rad in a book that both are some.is there any solution of this warning??Thanks. Link to comment https://forums.phpfreaks.com/topic/31457-solved-accessing-session-values/#findComment-145741 Share on other sites More sharing options...
JasonLewis Posted December 21, 2006 Share Posted December 21, 2006 do you have any breaks before the top of the page... any whitespaces or anything... it should look like this:[code=php:0]<?phpsession_start();[/code]exactly like that.... otherwise have this:[/code]<?phpsession_start();ob_start();//rest of phpob_end_flush();[/code]that will remove the error... Link to comment https://forums.phpfreaks.com/topic/31457-solved-accessing-session-values/#findComment-145743 Share on other sites More sharing options...
faraz Posted December 21, 2006 Author Share Posted December 21, 2006 thanks... it is working now. i just remove the space from the top. :) Link to comment https://forums.phpfreaks.com/topic/31457-solved-accessing-session-values/#findComment-145745 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.