Jump to content

Keep Adding value to a Session


isimpledesign

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.