isimpledesign Posted February 1, 2011 Share Posted February 1, 2011 How can i keep adding value to a session??? I need to somehow keep storing more values into an array. session_start(); // store session data $_SESSION['tune_name']=$_GET['tune_name']; $_SESSION['tune']=$_GET['tune']; print_r($_SESSION); So this is what i get from the print_r(); Array ( [attach] => Array ( ) [backups-2] => true [dnb] => true [house] => true [tech-house] => true [uk-garage] => true [uk-grime] => true [uk-hip-hop] => true [uncategorized] => true [warehouse] => true [views] => Music/dnb/Gold Dust (Vocal VIP Mix)_DJ Fresh_192.mp3 [tune_name] => Music/dnb/Dj Ss - We Came To Entertain (Sub Zero Remix).mp3 [tune] => Array ( ) ) ok what i need to do is everytime i click it saves that value above but just appends another value to the array so the session can keep getting larger and larger??? Any help please. Link to comment https://forums.phpfreaks.com/topic/226389-keep-adding-value-to-a-session/ Share on other sites More sharing options...
AbraCadaver Posted February 1, 2011 Share Posted February 1, 2011 $_SESSION['tune_name'][] = $_GET['tune_name']; $_SESSION['tune'][] = $_GET['tune']; Link to comment https://forums.phpfreaks.com/topic/226389-keep-adding-value-to-a-session/#findComment-1168489 Share on other sites More sharing options...
isimpledesign Posted February 1, 2011 Author Share Posted February 1, 2011 Thanks absolute legend spent ages trying to suss that. ok so i have got my array stored in the session now i need to loop through it here is the print_r(); Array ( [attach] => Array ( ) [backups-2] => true [dnb] => true [house] => true [tech-house] => true [uk-garage] => true [uk-grime] => true [uk-hip-hop] => true [uncategorized] => true [warehouse] => true [views] => Music/dnb/Gold Dust (Vocal VIP Mix)_DJ Fresh_192.mp3 [tune_name] => Array ( [tune_name] => Music/dnb/Awkward_Inside Info_192.mp3.asd [tune] => http://isdmusic.s3.amazonaws.com/Music/dnb/Awkward_Inside Info_192.mp3.asd [submit] => Listen [0] => Array ( [tune_name] => Music/dnb/03 Twerk feat. Yo Majesty (Sub Focus Remix).mp3 [tune] => http://isdmusic.s3.amazonaws.com/Music/dnb/03 Twerk feat. Yo Majesty (Sub Focus Remix).mp3 [submit] => Listen ) [1] => Array ( [tune_name] => Music/dnb/Abort_Delta Heavy_192.mp3 [tune] => http://isdmusic.s3.amazonaws.com/Music/dnb/Abort_Delta Heavy_192.mp3 [submit] => Listen ) [2] => Array ( [tune_name] => Music/dnb/Better Place_Dub Zero_192.mp3 [tune] => http://isdmusic.s3.amazonaws.com/Music/dnb/Better Place_Dub Zero_192.mp3 [submit] => Listen ) [3] => Array ( [tune_name] => Music/dnb/03 Twerk feat. Yo Majesty (Sub Focus Remix).mp3 [tune] => http://isdmusic.s3.amazonaws.com/Music/dnb/03 Twerk feat. Yo Majesty (Sub Focus Remix).mp3 [submit] => Listen ) ) [tune] => Array ( ) ) So i am looking to do something like this on another page. session_start(); $_SESSION['tune'] foreach ($_SESSION as $value) { echo $value['tune']; } I just want to loop through and grab the tune value. Any help thanks Link to comment https://forums.phpfreaks.com/topic/226389-keep-adding-value-to-a-session/#findComment-1168495 Share on other sites More sharing options...
AbraCadaver Posted February 1, 2011 Share Posted February 1, 2011 Try: echo "<pre>"; var_export($_SESSION); echo "</pre>"; And paste that output. if it isn't formatted correctly in the post then try the # tags instead of PHP. Link to comment https://forums.phpfreaks.com/topic/226389-keep-adding-value-to-a-session/#findComment-1168500 Share on other sites More sharing options...
isimpledesign Posted February 1, 2011 Author Share Posted February 1, 2011 Hi This is what i am getting from the print_r with pre wraps. Array ( [tune_name] => Array ( [0] => Array ( [tune_name] => Music/dnb/21st Century (Feat. Cabbie)_Tantrum Desire_192.mp3 [tune] => http://isdmusic.s3.amazonaws.com/Music/dnb/21st Century (Feat. Cabbie)_Tantrum Desire_192.mp3 [submit] => Listen ) [1] => Array ( [tune_name] => Music/dnb/Abort_Delta Heavy_192.mp3 [tune] => http://isdmusic.s3.amazonaws.com/Music/dnb/Abort_Delta Heavy_192.mp3 [submit] => Listen ) [2] => Array ( [tune_name] => Music/dnb/Abort_Delta Heavy_192.mp3 [tune] => http://isdmusic.s3.amazonaws.com/Music/dnb/Abort_Delta Heavy_192.mp3 [submit] => Listen ) [3] => Array ( [tune_name] => Music/dnb/21st Century (Feat. Cabbie)_Tantrum Desire_192.mp3 [tune] => http://isdmusic.s3.amazonaws.com/Music/dnb/21st Century (Feat. Cabbie)_Tantrum Desire_192.mp3 [submit] => Listen ) [4] => Array ( [tune_name] => Music/dnb/21st Century (Feat. Cabbie)_Tantrum Desire_192.mp3 [tune] => http://isdmusic.s3.amazonaws.com/Music/dnb/21st Century (Feat. Cabbie)_Tantrum Desire_192.mp3 [submit] => Listen ) [5] => Array ( [tune_name] => Music/dnb/03 Twerk feat. Yo Majesty (Sub Focus Remix).mp3 [tune] => http://isdmusic.s3.amazonaws.com/Music/dnb/03 Twerk feat. Yo Majesty (Sub Focus Remix).mp3 [submit] => Listen ) ) [attach] => Array ( ) [backups-2] => true [dnb] => true [house] => true [tech-house] => true [uk-garage] => true [uk-grime] => true [uk-hip-hop] => true [uncategorized] => true [warehouse] => true ) Link to comment https://forums.phpfreaks.com/topic/226389-keep-adding-value-to-a-session/#findComment-1168501 Share on other sites More sharing options...
isimpledesign Posted February 1, 2011 Author Share Posted February 1, 2011 So what i am trying to do is just loop through and grab the tune value. foreach ($_SESSION['value']['tune'] as $value) { echo $value['tune']; } Link to comment https://forums.phpfreaks.com/topic/226389-keep-adding-value-to-a-session/#findComment-1168505 Share on other sites More sharing options...
AbraCadaver Posted February 1, 2011 Share Posted February 1, 2011 foreach($_SESSION['tune_name'] as $value) { echo $value['tune']; } Link to comment https://forums.phpfreaks.com/topic/226389-keep-adding-value-to-a-session/#findComment-1168512 Share on other sites More sharing options...
isimpledesign Posted February 1, 2011 Author Share Posted February 1, 2011 Thanks for your time everything working great Link to comment https://forums.phpfreaks.com/topic/226389-keep-adding-value-to-a-session/#findComment-1168513 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.