djcritch Posted March 20, 2008 Share Posted March 20, 2008 Hi i have set up a php session using GET but having a bit of trouble calling the information, can anyone see what im doing wrong? heres what ive got: session_start(); foreach ($_GET as $key => $value) { $_SESSION[$key] = $value; } and to call it i have: <?php $_SESSION['url'] echo $_value; ?> but im guessing this is incorrect ? Link to comment https://forums.phpfreaks.com/topic/97048-how-do-i-call-this/ Share on other sites More sharing options...
berridgeab Posted March 20, 2008 Share Posted March 20, 2008 im guessing when you run that FOREACH loop, 'URL' is what is being passed over as the name of the session. You then store the Data in the session. So I think you would need: - <?php echo $_SESSION['url']; ?> Im not too sure what your trying to acheive with the code though so I'm not sure this is what you want. Also, if the $_GET fails, then there is no data to be stored in the session, so there would be no data to output. Link to comment https://forums.phpfreaks.com/topic/97048-how-do-i-call-this/#findComment-496622 Share on other sites More sharing options...
djcritch Posted March 20, 2008 Author Share Posted March 20, 2008 yea i have a form that goes to a.php which contains the session code but i then want to call it b.php and c.php but <?php echo $_SESSION['url']; ?> doesnt do the job cant understand why not? Link to comment https://forums.phpfreaks.com/topic/97048-how-do-i-call-this/#findComment-496635 Share on other sites More sharing options...
uniflare Posted March 20, 2008 Share Posted March 20, 2008 depending on your installation you need a "session_start()" at the top of each script using sessions. also depending on your installation you may need to pass a query string between pages that use sessions eg: www.url.com/index.php?PHPSESSID=3ui92grubf23yfgw34r the phpsessid is recognized by session_start(), Link to comment https://forums.phpfreaks.com/topic/97048-how-do-i-call-this/#findComment-496649 Share on other sites More sharing options...
djcritch Posted March 20, 2008 Author Share Posted March 20, 2008 ok thanks got it working now but getting this error message above it: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent any idea why? Link to comment https://forums.phpfreaks.com/topic/97048-how-do-i-call-this/#findComment-496673 Share on other sites More sharing options...
clown[NOR] Posted March 20, 2008 Share Posted March 20, 2008 session_start(); has to be put before any input.. all the way at the top of all your codes and HTML etc Link to comment https://forums.phpfreaks.com/topic/97048-how-do-i-call-this/#findComment-496684 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.