shg2001 Posted February 19, 2008 Share Posted February 19, 2008 You have program A it calls program B,the data stored in program A should be passed to program B using session, but when program A calls program B, program B has no data. Program A - Starts <?php session_start(); <code> .... ... <code> header("location: http://Program B.php"); Program B - Starts <?php session_start(); <code> .... ... <code> any though as to what i might be going wrong ... as to why the data does not pass from one program to another thanks SHG :'( Link to comment https://forums.phpfreaks.com/topic/91889-sessions/ Share on other sites More sharing options...
rhodesa Posted February 19, 2008 Share Posted February 19, 2008 Are program a and program b on the same domain and hosting service? You include an http:// in your header() which would lead me to believe they aren't. Link to comment https://forums.phpfreaks.com/topic/91889-sessions/#findComment-470556 Share on other sites More sharing options...
revraz Posted February 19, 2008 Share Posted February 19, 2008 Also, show the part where you set the session and retrieve it. Your code example is useless the way it is. Link to comment https://forums.phpfreaks.com/topic/91889-sessions/#findComment-470558 Share on other sites More sharing options...
shg2001 Posted February 19, 2008 Author Share Posted February 19, 2008 they are both on the domain and the same host Link to comment https://forums.phpfreaks.com/topic/91889-sessions/#findComment-470615 Share on other sites More sharing options...
shg2001 Posted February 19, 2008 Author Share Posted February 19, 2008 regarding retreiving the session. I don't honestly know if i am doing that correctly at all. I looked at all the documentation i could find and it all states use session_start(); at the top of each program. But in the docs it never gives you the code for the receiving program only the sending program...... So how do u retreive the session from the sending program??? thanks SG Link to comment https://forums.phpfreaks.com/topic/91889-sessions/#findComment-470622 Share on other sites More sharing options...
marcus Posted February 19, 2008 Share Posted February 19, 2008 Also, show the part where you set the session and retrieve it. Your code example is useless the way it is. Link to comment https://forums.phpfreaks.com/topic/91889-sessions/#findComment-470627 Share on other sites More sharing options...
rhodesa Posted February 19, 2008 Share Posted February 19, 2008 It should look something like this: pagea.php <?php session_start(); $_SESSION['test'] = "I was set in Page A"; header('Location: pageb.php'); exit; ?> pageb.php <?php session_start(); echo $_SESSION['test']; ?> Link to comment https://forums.phpfreaks.com/topic/91889-sessions/#findComment-470636 Share on other sites More sharing options...
shg2001 Posted February 19, 2008 Author Share Posted February 19, 2008 so how would you send and array?? Link to comment https://forums.phpfreaks.com/topic/91889-sessions/#findComment-470646 Share on other sites More sharing options...
rhodesa Posted February 19, 2008 Share Posted February 19, 2008 $_SESSION is an associative array in which you can assign key/value pairs. The values can be any PHP variable type. <?php session_start(); $_SESSION['test'] = array(); $_SESSION['test'][] = "I was set in Page A"; $_SESSION['test'][] = "I am another value in the array"; header('Location: pageb.php'); exit; ?> <?php session_start(); print_r($_SESSION['test']); ?> Link to comment https://forums.phpfreaks.com/topic/91889-sessions/#findComment-470650 Share on other sites More sharing options...
shg2001 Posted February 19, 2008 Author Share Posted February 19, 2008 <?php session_start(); $_SESSION['test'] = array(); $_SESSION['test'][] = "I was set in Page A"; $_SESSION['test'][] = "I am another value in the array"; header('Location: pageb.php'); exit; <?php session_start(); print_r($_SESSION['test']); ?> How would you print the second element of the array "I am another value in the array"; echo "this is the second Element".$_SESSION['test'][1]; Link to comment https://forums.phpfreaks.com/topic/91889-sessions/#findComment-470652 Share on other sites More sharing options...
rhodesa Posted February 19, 2008 Share Posted February 19, 2008 yup Link to comment https://forums.phpfreaks.com/topic/91889-sessions/#findComment-470661 Share on other sites More sharing options...
shg2001 Posted February 19, 2008 Author Share Posted February 19, 2008 Worked like a charm thanks so very much for all your help Link to comment https://forums.phpfreaks.com/topic/91889-sessions/#findComment-470670 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.