Set session variable on image click

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default Set session variable on image click

    Hi there guys,

    Having a problem...I want to set a language session variable when a user
    clicks on a flag which is in an image map on the index page.

    At the moment, the hotspot just links to 'index2', but how can I make it set a
    language variable and go to index2 also?

    This is a big hole in my CF knowledge, I hope someone can help me fill it!

    Thanks, Ben

    benkayuk 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. Click event on Image Control
      Hello , There is an Image control created on the page, the logic: when user clicks on the Image, it needs to perform some action(such as calling...
    3. Save variable on a click
      I have a menu made up of images where users can click an image to load the next page. I want each image to send a unique id number to the page the...
    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: Set session variable on image click

    In all honesty you are best to pass this as a URL variable and then set that to a session variable on the index2.cfm page.

    Make sense?
    Stressed_Simon Guest

  4. #3

    Default Re: Set session variable on image click

    Hi Simon,

    Ok makes sense....but how do I set the url to a session variable on the second page?

    Ben
    benkayuk Guest

  5. #4

    Default Re: Set session variable on image click

    <cfset URL.CountryID = SESSION.CountyID>
    Stressed_Simon Guest

  6. #5

    Default Re: Set session variable on image click

    OK, I've turned the image into sending an url variable 'lang'...so it gets to
    index2 as index2.cfm?lang=en

    On my index2.cfm page I have <cfset URL.lang = SESSION.lang> right at the top
    (above the <head> tag).

    That's the only coldfusion stuff I have at the top of that page. Now, when I
    go to site_root/dehler25/25boatoverview.cfm ....which is set to draw text from
    a DB WHERE lang = SESSION.lang I get nothing!!!

    I tested the overview page with a simple URL variable and it worked...is there
    somewhere I need to put something in an application.cfm file...or do I need
    more code at the top of index2.cfm ??

    Hope you can help me further, really appreciated,

    Ben

    benkayuk Guest

  7. #6

    Default Re: Set session variable on image click

    Sorry I assumed that you knew how to turn on SESSION variables.

    You need to put this in your Application.cfm:-

    <cfapplication
    name="yourApplicationName"
    sessiontimeout="#CreateTimeSpan(0, 0, 30, 0)#"
    sessionmanagement="yes">

    Stressed_Simon Guest

  8. #7

    Default Re: Set session variable on image click

    Hmm....well I had this already in my root directory...is that the place it
    should be?

    <cfapplication NAME="language">
    <cfapplication sessionmanagement="yes">
    </cfapplication>

    I'm not that bothered about it timing out...or should I be?

    Also, where does the application name link to? Because I have no mention of it
    anywhere else...i just chose it out of the blue!

    Ben

    benkayuk Guest

  9. #8

    Default Re: Set session variable on image click

    OK well basically the application name does not matter too much. It is just
    that if you change it at any point all the client, session and application
    variables will be reset.

    As for the timeout, that is how long the session variables will last if there
    is not action by the user. Basically how long they can leave their browser idle
    before the variables are deleted from Application memory. The value set here
    overides the default set in the CF administrator, but will not be able to be
    above the max set in CF Admin.

    I have never used cfapplication with a closing tag, I am pretty sure it
    doesn't work. try how I showed you and if it works then it should answer you
    question!

    Stressed_Simon Guest

  10. #9

    Default Re: Set session variable on image click

    OK, changed my application.cfm but still no joy.

    I sometimes get an error on my index2.cfm page even when I click through from
    the language selection page (index.cfm)....

    All I have at the top of index2.cfm is...

    <cfset URL.lang = SESSION.lang>
    <html>
    <head>
    <link rel="shortcu........

    Is that really all that is required up there?

    The error I sometimes get on index2.cfm is :

    Element LANG is undefined in SESSION.


    The error occurred in C:\CFusionMX7\wwwroot\CFIDE\dehler\index2.cfm: line 1

    1 : <cfset URL.lang = SESSION.lang>
    2 : <html>
    3 : <head>


    Hope you have a clue! Ben

    benkayuk Guest

  11. #10

    Default Re: Set session variable on image click

    Well a good start would be renaming application.cfm to Application.cfm. Also check that Session variables are enabled in the CF administrator!
    Stressed_Simon Guest

  12. #11

    Default Re: Set session variable on image click

    Yep, changed to Application.cfm and session variables are (were already)
    enabled.

    What I don't understand is why I get the message Lang is undefined in Session,
    when the only command on the index2.cfm page is to actually SET the session in
    the first place!

    Any ideas?
    Ben

    benkayuk Guest

  13. #12

    Default Re: Set session variable on image click

    I am so sorry I have been half asleep here. I got it the wrong way round.

    <cfset SESSION.Lang = URL.Lang>
    Stressed_Simon Guest

  14. #13

    Default Re: Set session variable on image click

    Hahaha, jeez that solved everything!!

    Then again, I should have spotted it too! lol

    Thanks for all your help!

    Ben
    benkayuk Guest

  15. #14

    Cool Re: Set session variable on image click

    Hi, I'm also having problem with the session variables in cf. Well, it is really my first time to use cf in my web dev., and i becoming to like really. Implementing of queries is awesome so simple and manipulating at the same time. But every thing looks fine until I reached session part w/c really give me headache dealing with it. Unlike sesssion variables in php quite ease to handle but cf, i'm really having trouble, I can't get it. @Stressed_Simon, you know what I did in order to prevent the problem you encountering "undefined", I create file for my application and include it in all my pages... But the trick works, just don't sure if it the correct way.
    Amadeyo 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