Adding to the session variable

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Adding to the session variable

    Yeah that is pretty much my questions. I am building a web playlist, and I need
    a way for people to add songs to it. So what I have is a checkbox by every
    song, and then the ones they check get added to a playlist session variable. My
    question is, how do I ADD the form contents to the session variable, without
    deleteing the old stuff. I have tried the following things

    <cfset #session.playwhat# = #session.playwhat# + form.playwhat>
    and
    <cfset session.playwhat = Structappend(session.playwhat,form.playwhat)>

    neither of those have worked. How to I do it?



    kenji776 Guest

  2. Similar Questions and Discussions

    1. #39634 [NEW]: session variable and normal variable
      From: erhanbaris at gmail dot com Operating system: Win Xp SP1 PHP version: 5.2.0 PHP Bug Type: Variables related Bug...
    2. Adding Double Quotes to variable
      I currently have a variable called $servicename. Example: SNMP Service = $servicename How can add double qoutes around "SNMP Service" to the...
    3. adding text to variable
      I have an email login screen that sends the username and password to an authentication screen. I designate the username with the name of the input,...
    4. Datalist - how (if) to use a sub variable or session variable in the footer?
      Hi, sorry to be greedy with all my posts lately, but can you tell I'm doing new things this week? I've just done my first datalist (a simple...
    5. [SESSION] Session variable deleted prior to command?
      Hi all, I'm developing a database system on my local computer (OS/version details at bottom) with a simple user authentication using sessions. On...
  3. #2

    Default Re: Adding to the session variable

    Try:

    <cfset #session.playwhat# = #session.playwhat# & form.playwhat>

    bill_doe Guest

  4. #3

    Default Re: Adding to the session variable

    Thank that worked like a charm. Now another thing. What would be a good way to
    keep boxes check that have already checked so they don't check then again. Like
    say they chooose some songs from the F section, then go to the G section choose
    some more, and then go back to F, I want the songs they choose in F to stay
    checked. I know there is some kind of way to read from the session variable and
    find out whether it should be checked or not. Here is the code I use to make
    the checkboxes.



    <form name="form" method="post">
    <cfdirectory action="list" directory="d:\ftp\digital
    swordsmen\downloads\music\" name="music_dump" filter="*.mp3">

    <cfloop query="music_dump">
    <cfif Left(#music_dump.name#, 1) EQ #url.letter#>
    <cfoutput>

    <table width="500" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td width="10"><a href="../Downloads/music/#music_dump.name#"
    target="_blank"><img src="IMG/AlienDe0.gif" width="12" height="12"
    border="0"></a></td>
    <td width="450"><a
    href="../Downloads/music/#music_dump.name#">#music_dump.name#</a></td>
    <td width="15"><input type="checkbox" name="Playwhat" id="playwhat"
    value="Songname_#music_dump.name#"> </td>
    </tr>
    </table>
    </cfoutput>

    <cfelse>

    </cfif>
    </cfloop>

    <br>
    <input name="Playsongs" type="submit" id="Playsongs" value="Play songs in
    list">
    <input name="addsongs" type="submit" id="addsongs" value="Add songs to list
    and keep browsing">
    </form>

    kenji776 Guest

  5. #4

    Default Re: Adding to the session variable

    If you use
    <cfset #session.playwhat# = #session.playwhat# & form.playwhat>
    How can you tell where the name of 1 song starts and another begins. I would
    think
    you should use a list.

    <cfset session.playwhat = ListAppend(session.playlist,form.playlist)>

    You shouldn't put pound signs on the left side of the cfset assignment.

    OldCFer Guest

  6. #5

    Default Re: Adding to the session variable

    Hmm. I though the songs would be seperated by commas when stored in the session
    variable like that. I mean i dumped the variable afterwards and i saw
    song1.mp3,song2.mp3,song3.mp3 and so on, so like it does seperate with commas.
    Does the listing way do something better? Not trying to like question you or
    anything, just trying to figure out why that is the better way to do it. Thanks
    for the help.

    kenji776 Guest

  7. #6

    Default Re: Adding to the session variable

    The only way you would get commas in there is if you have multiple fields named
    form.playwhat.
    <cfset x = "mary">
    <cfset x = x & "jane">

    produces "maryjane" not "mary,jane". "&" means put the two strings together,
    not separate them with a comma.

    OldCFer Guest

  8. #7

    Default Re: Adding to the session variable

    Wouldn't I want them seperated by commas so when i go to feed them into a media player I can use a comma delimited loop?
    kenji776 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139