Login Session Variable Problem

I've created a simple login using the inbuilt DW suite, but I don't seem to be able to display the session variable after they login.
On the success page it should filter the RS based on the Username and also display the Username etc on the page but nothing is shown. I tested the success page in DW and entered a value for the session var and it works fine, all I can think of is that the session is empty, not coming through, but I'm clueless.
Any ideas?
<<<<<LOGIN PAGE>>>>>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
if (isset($_POST['UserName'])) {
  $loginUsername=$_POST['UserName'];
  $password=$_POST['Password'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "login_successful.php";
  $MM_redirectLoginFailed = "login.php";
  $MM_redirecttoReferrer = true;
  mysql_select_db($database_connpbxlogin, $connpbxlogin);
  $LoginRS__query=sprintf("SELECT UserName, UserPassword FROM Users WHERE UserName=%s AND UserPassword=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
  $LoginRS = mysql_query($LoginRS__query, $connpbxlogin) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;     
    if (isset($_SESSION['PrevUrl']) && true) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
    header("Location: " . $MM_redirectLoginSuccess );
  else {
    header("Location: ". $MM_redirectLoginFailed );
?>
<<<<<SUCCESS PAGE>>>>>
$colname_LoggedRS = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_LoggedRS = $_SESSION['MM_Username'];
mysql_select_db($database_connpbxlogin, $connpbxlogin);
$query_LoggedRS = sprintf("SELECT * FROM Users WHERE UserName = %s", GetSQLValueString($colname_LoggedRS, "text"));
$LoggedRS = mysql_query($query_LoggedRS, $connpbxlogin) or die(mysql_error());
$row_LoggedRS = mysql_fetch_assoc($LoggedRS);
$totalRows_LoggedRS = mysql_num_rows($LoggedRS);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
</p>
<p>username: <?php echo $row_LoggedRS['UserFirstName']; ?></p>
<p>email: <?php echo $row_LoggedRS['UserEmail']; ?></p>
<p>Session Data:
  <?php echo $_SESSION['MM_Username']; ?></p>
</body>
</html>
<?php
mysql_free_result($LoggedRS);
?>

Does your success page begin with session_start()?

Similar Messages

  • Login session variable - pls help before i slot myself

    im brand new to this guys and really struggling with logging
    in a member to their particular account as opposed to a general
    members section using dreamweavers login application and some basic
    php coding.
    i just cant seem to figure it out it (im stuck on the session
    variables i think..) and unfortunately my php is very poor at them
    moment!
    pls HELP!!
    below is the dreamweaver generated code from its basic login
    application.
    im using it in a dreamweaver template so im not sure if thats
    the issue but bascially im using 2 SQL tables i constructed to
    achieve this-
    1.) tblaccesslevel
    intLevelID (unsigned + auto increment + primary key)
    txtAccess
    (ive allocated various numerical access levels into
    txtAccess. ie. 1-7
    and
    2.) tblplayeraccount
    intUserID (unsigned + auto increment + primary key)
    txtFirstName
    txtLastName
    txtEmailAddress
    txtPassword
    intAccessLevel
    (ive generated 2 users in the above table tp test)
    in dreameavers server behaviors the recordset generated by
    the login server behavior simply says Log In User
    obviously i need a session variable somewhere to get the
    intUserId....
    also a relationship needs to be generated in the sql
    statement to connect the intAccessLevel but i think i can manage
    that (i think..)
    below is the code this application generated -
    if someone can give me some hints or if they've done
    something similiar pls provide the required code ...it would be a
    huge help!! i dont know what im doing wrong!!!
    <?php require_once('../Connections/Rugby.php'); ?>
    <?php
    // *** Validate request to login to this site.
    if (!isset($_SESSION)) {
    session_start();
    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($_GET['accesscheck'])) {
    $_SESSION['PrevUrl'] = $_GET['accesscheck'];
    if (isset($_POST['emailaddress'])) {
    $loginUsername=$_POST['emailaddress'];
    $password=$_POST['password'];
    $MM_fldUserAuthorization = "intAccessLevel";
    $MM_redirectLoginSuccess = "../player_home.php";
    $MM_redirectLoginFailed = "../failed.php";
    $MM_redirecttoReferrer = false;
    mysql_select_db($database_Rugby, $Rugby);
    $LoginRS__query=sprintf("SELECT txtEmailAddress, txtPassword,
    intAccessLevel FROM tblplayeraccount WHERE txtEmailAddress='%s' AND
    txtPassword='%s'",
    get_magic_quotes_gpc() ? $loginUsername :
    addslashes($loginUsername), get_magic_quotes_gpc() ? $password :
    addslashes($password));
    $LoginRS = mysql_query($LoginRS__query, $Rugby) or
    die(mysql_error());
    $loginFoundUser = mysql_num_rows($LoginRS);
    if ($loginFoundUser) {
    $loginStrGroup = mysql_result($LoginRS,0,'intAccessLevel');
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;
    if (isset($_SESSION['PrevUrl']) && false) {
    $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
    header("Location: " . $MM_redirectLoginSuccess );
    else {
    header("Location: ". $MM_redirectLoginFailed );
    ?>

    Are you wanting to redirect them to a specific page based on
    their username or to the same page with dynamic content based on
    their username?

  • OBIEE Session Variable Problem

    Hi:
    OBIEE 11.1.1.5
    I created a new session variable and initialization block. The default value of the variable is 1. The query for the initialization block is SELECT 123456 FROM DUAL. The query in the initialization block tested fine. I bounced the OBIEE instance.
    When I use the Administration Tool to view the Session Manager, I see that the value of the variable is 123456.
    The problem is in an Answers report the value of the variable is 1.
    Can anyone offer a suggestion as to why the value in Answers is the default value of the variable?
    Thanks.

    Thanks for your reply. I agree that the expression NQ_SESSION. <<variable name>> will display the variable. And it is with this command, in Answers, that I see the default value. Only in the Admin Tool do I see the correct value assigned with the Initialization Block.
    Again, my problem is I cannot display the correct assigned value in an Answer report, only the default value.

  • Session variable problem : equality comparisons

    I have defined the following session variable returning the error *"[nQSError: 10058] A general error has occurred. [nQSError: 42040] The session variable, NQ_SESSION.TEST, is defined as Row-Wise Initialization. It is restricted to usage with equality comparisons. (HY000)"*
    select 'TEST', organisatie_nummer
    from st_organisatie
    where (select case when regio = -1 then 1 else
    regio_nummer end
    from st_gebruikers
    where upper(gebruiker) = upper('VALUEOF(NQ_SESSION.USER)')) =
    (select case when regio = -1 then '1' else regio end
    from st_gebruikers
    where upper(gebruiker) = upper('VALUEOF(NQ_SESSION.USER)'))
    Why this setup...a user can have access to 1 region or 'ALL' region. To make the 'ALL' available a dummy records has been inserted with a value of -1.
    There's no problem to retrieve the region (another session variable), it returns '%' in case a user has all regions or the region name itself.
    But i wanted to use this variable to retrieve the organisations linked to a region, but using a like statement or the query above isn't possible as it always returns the same error.
    Someone any idea how to resolve this?!
    Txs,
    Andy

    [nQSError: 10058] A general error has occurred. [nQSError: 42040] The session variable, NQ_SESSION.ORGANISATIE, is defined as Row-Wise Initialization. It is restricted to usage with equality comparisons. (HY000)
    I transformed my query like this, I don't have any clue why this isn't working...if I run this sql statement it works perfect but not in OBi
    select 'ORGANISATIE', organisatie_nummer
    from st_organisatie
    ,(select gebruiker,regio from st_gebruikers) b
    where case when b.regio = -1 then 1 else regio_nummer end
    like
    case when b.regio = -1 then '%' else b.regio end
    and upper(gebruiker) = upper(':USER')

  • Using Session Variables for User Login - sometimes they don't persist... what am I doing wrong?

    Hi all,
    I'm running a site that requires user login.  I approached the building of this site as almost a complete newb to CF (and dynamic coding in general), and it's been a great learing experience (with lots of help from you guys).
    However, I guess I never learned the correct way to handle a user login.  It seemed to me that I could just test the user-entered credentials against those stored in a database, then set a session variable containg that user's record number.  Then, not only would I have an easy way of knowing who this user was and therefore what info to serve him, but I could test for the existence of a valid login on every page in the protected folder, by adding this code to my application.cfc in that folder:
    <cfset This.Sessionmanagement=true>
    <cfset This.Sessiontimeout="#createtimespan(0,8,0,0)#">
       <cfif NOT isDefined ("session.username") or NOT isDefined ("session.password") or NOT isDefined ("session.storeID")>
         <cflocation url="../index.cfm" addtoken="no">
       </cfif>
    ...and it goes on to run a query and verify that the session.username and session.password match for the store defined by session.storeID.  If not, all session variables are cleared and it bounces you back to the login page.  When the user clicks Logout, all I do is delete all the session variables.
    This seemed to work great for like a year, but lately I've been getting reports that the login doesn't seem to persist for longer than approx. 20 minutes of inactivity.  You can see I specified session variables to remain active for 8 hours (I know that seems like a drastically long login, but it's what's necessary for this application).  I've only gotten this report from a few people, and I myself can't seem to duplicate it... I've tested an inactive login for 45 minutes now and it held.
    SO:  any reason you can think of why session variables would be spontaneously clearing for some people?  Would having your router reset its IP address invalidate the session or something?  Also, the problem seemed to begin appearing after my host upgraded all their servers to CF9... could there be any relation?
    And on a more general note... did I go about this completely the wrong way to begin with?  If so, what's the standard way to manage a login?
    Lots of questions, I know... thanks very much for any answers or suggestions!
    Joe

    Ian,
    Thanks very much - very helpful information.
    Sounds like passing the tokens in every request is probably the way to go for this.  I don't think it's likely that any users will be sharing links, unless they actually intend for the recipient to see their info anyway.
    Is that all I would have to do, is add the tokens to every path?  Would that guarantee that all the session variables would remain valid until timeout or being cleared?
    Again, thanks, you've been really helpful.
    Joe
    On Jun 23, 2010 4:37 PM, Ian Skinner &lt;[email protected]&gt; wrote:
    Unfortunately this is the nature of HTTP web applications.  There is NO state maintained from HTTP request to request.  This is by design in the HTTP protocol specifications.
    ColdFusion provides two methods to circumvent this limitation.  Each method has limitations and caveats.  They both rely on the passing of tokens between the client and the server with every request.  These tokens can be passed as cookies OR URL (GET) variables.  You are using the cookie method, which is the simpler and most common. You may be experiencing the limitation of this method.  If something happens to the cookies the session can be lost.
    You could pass the (CFID &amp; CFTOKEN) OR JESSIONID tokens through the URL query string with every request.  This requires one to add these values to every link, form action, cflocation or other request path in our application.  ColdFusion provides the session.urltoken variable to make this easier to do.  The tokens will be visible to the user.  Also if the links with an individual token is share with other users, via e-mail, chat, social networks, etc and one of these users utilize the link during the life of a session (8 hours apparently in your case).  Then that user will access the session of the original user.
    Cookie session management is by far the most common choice by CF developers.  If these methods do not meet your needs you would need to go beyond the HTTP limitations of web applications.  One might be able to accomplish this with a Flex|Air|Flash applications that can be configured to use a continuous connection to the server.  Thus not suffer the stateless nature of the normal HTTP request-response cycle.
    I do not know if a router resetting would cause cookies to be discarded or otherwise invalidated.  But I would not think it is beyond the relm of possibilities.

  • Problem with Session variable initialization block

    Hi,
    I'm getting strange results when using session variables in my repository files.
    I have created session variables as specified in the document which is available at
    http://www.oracle.com/technology/obe/obe_bi/bi_ee_1013/bi_admin/biadmin.html
    The main problem getting with the system session variable (USER) in the select statement.
    My select statement is as follows,
    select ':USER',case when upper(':USER') = 'KUMAR' then 'APR-05' end from Dual
    The problem is while logging into the BI Answers it is allowing all the invalid users to login who does not exist.
    when i remove the quotes and simply use :USER in the select statement it is not allowing the invalid users to login but giving error while displaying the results.
    when i remove the user variable from select statement its giving correct results.
    Can i know what is causing the problem.
    Thanks,
    Kumar.

    Hi DK,
    Check out my post Rowlevel Security?? and see if it helps you.
    Cheers!
    -Joe

  • Purchased ColdFusion 10: Having problem with session variables

    My Dept. has just bought CF10 and I'm finally updating my existing web app to CF10 from CF8. My First Problem with CF10 is using session variables.
    When using the lower version of CF (since CF 4 to 8) I have never had any problem setting up session variables and getting or using these variables in other pages after a successful login but with CF 10 it seems setting session variables and using them in other pages are a major problems. I'm not sure where have I done wrong in the codes.
    First I'm setting the session in my Application.cfc This way:
    <cfcomponent displayname="Application" output="true">
      <cfset THIS.Name ="MyNewApp"/>
      <cfset THIS.ApplicationTimeout = CreateTimeSpan(0,0,20,0) />
      <cfset THIS.SessionManagement ="YES"/>
      <cfset THIS.SessionTimeout = CreateTimeSpan( 0, 0, 20, 0 ) />
      <cfset THIS.SetClientCookies = false />
    <cffunction name="OnApplicationStart" access="public" returntype="boolean" output="false">
    <cfset application.Main_DSN = "TESTDB">
    <cfreturn true />
    </cffunction>
    <cffunction name="onApplicationEnd" output="false">
          <cfargument name="applicationScope" required="true">
        </cffunction>
    <cffunction name="OnSessionStart" access="public" returntype="void" output="false" hint="Fires when user session initializes.">
    <cfset session.loggedin = "NO">
    <cfset session.username = "">
    <cfset session.userrights = "">
    <cfset session.usergroup = "">
    </cffunction>
    </cfcomponent>
    After login, user is validated and set values to those session.variables:
    ........user validation codes here......................
    <cfif mylogin NEQ true>
          <cflocation url="/login/login.cfm">
          <cfabort
    <cfelse>
          <cfset session.loggedin="Yes">
          <cfset session.username="#Trim(Form.username)#">
         <CFSET qUserRights = LoginObj.getUserRights('#Trim(Form.username)#')>
         <cfset session.userrights = qUserRights><!--- it's a query --->
        <CFSET qUserGroup = LoginObj.getUserGroup('#Trim(Form.username)#')>
            <cfloop query="qUserGroup">
               <cfset session.usergroup = user_group>
               <cfbreak>
            </cfloop>
        <!--- ****************** ???????????????????????????????????????????????????????????????????????????
        When I do cfdump in at this level, I can see that all of these session variables have been assigned to their values.
        But these session variables are not accessible from other pages. Other pages still show these session variable without its value.
        So, when I use these cfdumps in the index.cfm it is shown as they're not yet assigned with any values   ****************** --->
       <cfdump var="#session.loggedin#">
       <cfdump var="#session.username#">
       <cfdump var="#session.userright#">
       <cfdump var="#session.usergroup#">
    </cfif>
    In index.cfm, Before Login I got:
    session.loggedin = NO
    session.username = ["empty string"]
    session.userrights = ["empty string"]
    session.usergroup = ["empty string"]
    After a successful Login:
    session.loggedin = NO
    session.username = ["empty string"]
    session.userrights = ["empty string"]
    session.usergroup = ["empty string"]
    Have I done something wrong? These codes work on CF8. Please help.
    I need to mentioned:
    CF10 is in Linux and my web app is under https not http. But these session variables should be shared bentween http and https because some older application are still in http.

    On which page is the following code?
    After login, user is validated and set values to those session.variables:
    ........user validation codes here......................
    <cfif mylogin NEQ true>
          <cflocation url="/login/login.cfm">
          <cfabort
    <cfelse>
          <cfset session.loggedin="Yes">
          <cfset session.username="#Trim(Form.username)#">
         <CFSET qUserRights = LoginObj.getUserRights('#Trim(Form.username)#')>
         <cfset session.userrights = qUserRights><!--- it's a query --->
        <CFSET qUserGroup = LoginObj.getUserGroup('#Trim(Form.username)#')>
            <cfloop query="qUserGroup">
               <cfset session.usergroup = user_group>
               <cfbreak>
            </cfloop>
        <!--- ****************** ???????????????????????????????????????????????????????????????????????????
        When I do cfdump in at this level, I can see that all of these session variables have been assigned to their values.
        But these session variables are not accessible from other pages. Other pages still show these session variable without its value.
        So, when I use these cfdumps in the index.cfm it is shown as they're not yet assigned with any values   ****************** --->
       <cfdump var="#session.loggedin#">
       <cfdump var="#session.username#">
       <cfdump var="#session.userright#">
       <cfdump var="#session.usergroup#">
    </cfif>

  • Add additional session variable on login?

    Hi,
    at first, sorry for my bad englisch. Maybe anyone here can speak german.
    Is there any way to save an additonal session variable on login without it is required to store this variable in a table column.
    A short description:
    I have a member table, that contains the login information (id, password, level) and further information about the member. A second table contains different sportevents.
    Now i would create a login form, which has 3 input fields, one for the member id, one for the password and one select field, who the member can choose the sportevent. For further work, i need the member id, the member level and the sportevent id as a session variable. There is no problem, with the member id and the level id, this both variables i can get with the ADDT login wizard, but how can i safe the event id during the login as session variable?
    Can anybody help me?
    Thanks in advance.
    Rico

    Hi Rico,
    Maybe anyone here can speak german
    na komm, dein Englisch ist ziemlich gut, und ich möchte deine Frage lieber in Englisch beantworten, damit andere ADDT-User auch was davon haben :-)
    There is no problem, with the member id and the level id, this both variables i can get with the ADDT login wizard, but how can i safe the event id during the login as session variable?
    What I´m saying now, is somewhat experimental, because I didn´t try that myself so far -- but I think this should work:
    a) add another numeric (int) column to your ADDT login table that´s going to hold the selected value from your "events" menu -- let´s call this column "current_event_id"
    b) on the login page: create a recordset which retrieves the "event_id " and "event_name" values from your "sportevents" table -- guess that´s what you already did for populating the "events" menu you mentioned
    c) switch the login page to CODE. When scrolling down, you´ll see these 2 lines below the // Add columns comment:
    $loginTransaction->addColumn("kt_login_user", "STRING_TYPE", "POST", "kt_login_user");
    $loginTransaction->addColumn("kt_login_password", "STRING_TYPE", "POST", "kt_login_password");
    below that, add another line like this:
    $loginTransaction->addColumn("current_event_id", "NUMERIC_TYPE", "POST", "events");
    In order to convert the submitted "events" menu - value to a session variable, you should add the new column "current_event_id" to ADDT´s list of default session variables
    (Control Panel)
    Does that work ?
    Cheers,
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • Problem with session variable

    Hi,
    After I insert a record into my MS Access database, it seems
    to me that the session variable got destroyed so the next page
    display the session variable as undefined. Has anyone have similar
    problem? If so, how to work around that?
    Thanks.
    Tommy,

    neptunes wrote:
    but its leading to jsp page error...For starters: never, never, ignore errors (exceptions and stacktraces). Those contain very, very, worthful information about the cause of the problem and what exactly went wrong. This way you can easily trackback the problem and solve it.
    If you're unable to think logically and smart so that you can interpret the error yourself, if necessary with help of Google, then post it here. Then we'll tell you about the actual problem and possible soltions.
    At any way:
    iam displaying some data in a table using resultset object,now at the same time iam using to session variable to use the resultset object in my other applications...This already doesn't sound very good. You should never pass expensive resources around like that. You should acquire and close the Connection, (Prepared)Statement and ResultSet in the shortest possible scope. Preferably already in the same method as where you query the data.

  • Problem retrieving Session variables in Flex from Coldfusion

    For about a year I've been using a cfc that allows me to remote call from within Flex to retrieve session-level variables.  I much prefer this to using FlashVars because with the remote call the session values don't show up in the page source.
    This was working fine when I was using an Application.cfm file to manage my Coldfusion pages.  However when I switched to using an Application.cfc file, the cfc stopped working.  Neither the cfc or the cfm file contain any code to manage these session variables (they are set in other pages), so the only real difference seems to be changing from Application.cfm to Application.cfc.
    Any thoughts why?  Thanks.

    Ok, this is resolved.
    The problem seems to have been related to the scope of Application.cfc and Application.cfm.  The directory which contained the cfc files had an Application.cfm controlling the session, while the directory with the pages that included the flex swf files had an Application.cfc file.  Apparently these two don't talk to each other.
    The solution is to use either Application.cfc or Application.cfm files, but not to mix them.  In other words, use either -- but be consistent.

  • Problem in session variables

    hi ,
    Is it not correct to assume that ones we close the browser the session losts and all the session variables also?
    Actually i have design an authentication page which takes userid and password from user and supply this to servlet which after authentication sets a variable "validity" in session to true.
    And in every other jsp page first i m checking this variableis true or not if not then i m redirecting it to authentication page with this tag
    <jsp:forward page="authentication.jsp" />
    now if i have authenticated correctly and close browser and try to access other pages directly then browser allows me to access any page and infact when i print "validity" variable from session then it prints true. That means even after closing the browsing session remains.
    I tried to print session id then after opening a new browser it is showing the same browser.
    In web.xml file i have mentioned the session time to 60 minutes . Is it because of this?. If it then how these standard sites sun, yahoo maintains session time out as well as browser dependent session.
    Right now what i have to do is before setting the variable i have reset the variable to null. But wher shud i reset the validity variable . in destroy method?
    manish

    Your problem is not due to session time out in the xml
    file.
    I think whenever you close your browser the session
    does not exists.
    Remember to invalidate the session while logging off.
    It should workThat is not true. The session will exist for as long as the session timout option is set. Although invalidating the session at logoff is a good idea, there is no real method to force people to log off when the leave your site/close the browser.
    There are a couple of possibilities why the session would still be used after a browser is closed, although normal behavior is to create a new one. The main reason is because the cookie on the browser that maintains the jsessionid is not destroyed. This often occurs in browsers like NS 7 with a "quick-load" app running in the taskbar area (next to the clock). These little parts of the application never close, and hold on to browser cache and cookies, so as to make it quicker to open and surf.
    How do you ge around this? I do not know, except perhaps by preventing the session from using cookies for tracking...

  • Problems accessing session variables from a pop-up

    I am working on a webapp and I when I click on a certain button I need to have a pop-up appear that will either prompt a user to enter log-in info if they haven't already, otherwise the pop-up just needs to display a report. Users can navigate around on the main page and select various reports so multiple pop-ups could possibly be opened. When a user logs in I save the login info in session variables, but for some reason whenever I click to have another pop-up open it always says that my session variables are null. Is there a way to have more global session variables so that multiple windows (the pop-ups) can touch session variables? Would there be a way to pass the login info in session variables back to the main page and then pass those session variables back out to each pop-up that opens? Thanks so much.

    Have you got session cookies enabled?
    The most common way to keep track of the session id is via a session cookie.
    This cookie gets shared by all windows of the same browser session.
    You are opening these pop-up windows with window.open?
    Print out the session id <%= session.getId() %> on each page to see if it is the same.
    Cheers,
    evnafets

  • Problem passing Session variable as URL parameter?

    Hi,
    I am trying to create a multiple page entry form using
    coldfusion session. But I am having some problem when passing the
    session variable to url parameter. For test purpose I have created
    the following code:
    <cfif Not IsDefined("SESSION.AE")>
    <!--- If structure undefined, create/initialize it
    --->
    <cfset SESSION.AE = StructNew()>
    <!--- Represent current form srep; start at one --->
    <cfset SESSION.AE.StepNum = 1>
    </cfif>
    <cfif IsDefined("Form.GoBack")>
    <cfset SESSION.AE.StepNum = #url.StepNum# - 1>
    <cfelseif IsDefined("Form.Next")>
    <cfset SESSION.AE.StepNum = #url.StepNum# + 1>
    </cfif>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1">
    </head>
    <body>
    <form method="post"
    action="/AE/try.cfm?StepNum=#SESSION.AE.StepNum#">
    <input type="submit" name="GoBack" value="Back">
    <input type="submit" name="Next" value="Next">
    </form>
    </body>
    </html>
    When run it I get the following error:
    The value "" cannot be converted to a number
    The error occurred in C:\CFusionMX\wwwroot\AE\try.cfm: line
    11
    9 : <cfset SESSION.AE.StepNum = #url.StepNum# - 1>
    10 : <cfelseif IsDefined("Form.Next")>
    11 : <cfset SESSION.AE.StepNum = #url.StepNum# + 1>
    12 : <!---<cfset SESSION.AE.StepNum = #url.StepNum# +
    1>--->
    13 : </cfif>
    I couldn't figure out where is the problem. Any help is
    really appreciated.
    Thanks in advance.

    You are mixing up your gets and posts aren't you?
    You have your form method set to post which creates form
    variables not
    url variables. So when you try to use the url variable to set
    your
    session it does not exist.
    Change your SESSION.AE.StepNum = #url.StepNum# to
    Session.AE.StepNum =
    form.StepNum, note there is no need for the #'s.
    OR
    change your form method="post" to form method="get"
    Nagelia wrote:
    > Hi,
    >
    > I am trying to create a multiple page entry form using
    coldfusion session. But
    > I am having some problem when passing the session
    counter to url parameter. For
    > test purpose I have created the following code:
    >
    > <cfif Not IsDefined("SESSION.AE")>
    > <!--- If structure undefined, create/initialize it
    --->
    > <cfset SESSION.AE = StructNew()>
    > <!--- Represent current form srep; start at one
    --->
    > <cfset SESSION.AE.StepNum = 1>
    > </cfif>
    > <cfif IsDefined("Form.GoBack")>
    > <cfset SESSION.AE.StepNum = #url.StepNum# - 1>
    > <cfelseif IsDefined("Form.Next")>
    > <cfset SESSION.AE.StepNum = #url.StepNum# + 1>
    > </cfif>
    >
    > <html>
    > <head>
    > <title>Untitled Document</title>
    > <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1">
    > </head>
    > <body>
    > <form method="post"
    action="/AE/try.cfm?StepNum=#SESSION.AE.StepNum#">
    > <input type="submit" name="GoBack" value="Back">
    > <input type="submit" name="Next" value="Next">
    > </form>
    > </body>
    > </html>
    >
    > When run it I get the following error:
    >
    > The value "" cannot be converted to a number
    >
    >
    > The error occurred in C:\CFusionMX\wwwroot\AE\try.cfm:
    line 11
    >
    > 9 : <cfset SESSION.AE.StepNum = #url.StepNum# - 1>
    > 10 : <cfelseif IsDefined("Form.Next")>
    > 11 : <cfset SESSION.AE.StepNum = #url.StepNum# +
    1>
    > 12 : <!---<cfset SESSION.AE.StepNum =
    #url.StepNum# + 1>--->
    > 13 : </cfif>
    >
    > I couldn't figure out where is the problem. Any help is
    really appreciated.
    >
    > Thanks in advance.
    >
    >
    >
    >

  • JSP Session in JavaScript variable problem

    Hi,
    I have a session variable msgSize that is being set by a Java file in the session.
    aRequest.getSession().setAttribute("msgSize", msgSize);It's value is variable depends on record count of recordset.
    In JSP page where I have to assign it's value to a javascript variable. I am doing this a s follows. I have done this in the JSP file.
    <script type="text/javascript" >
    <!--
    function getVal()
    m=${msgSize};
    -->
    </script>First Problem is I am unable to get this value inside a External JS file. It throws error but inside jsp it is working. How can i use this inside External JS?
    Second problem is once the above code executed value never refreshed to new value?
    Means first time it executed it get value 200 next time again i executed the code the real recordset is 105 but still displaying 200. But when I restart the server next time it takes value 105 by itself....
    How I tackle this problem.?
    Regards,

    problem is I am not refreshing the whole JSP page everytime, only refreshing the partial page using ajax call that's why not getting the session new value...
    any suggestions what to do to get new value?

  • Problem accessing session variables in JSP

              Hi all,
              i am retrieving the value of session variables in a JSP page. the session varibale
              is set at the
              server side. sometimes the jsp is able to retrieve the value and sometimes it
              doesn't.
              Thanks & Regards
              Tarun
              

    if getAttribute return null so there is no such session attribute,anyway
              check your browser if cookies are enabled.
              "Tarun Mangal" <[email protected]> wrote in message
              news:400759e9$[email protected]..
              >
              > Hi all,
              > i am retrieving the value of session variables in a JSP page. the session
              varibale
              > is set at the
              > server side. sometimes the jsp is able to retrieve the value and sometimes
              it
              > doesn't.
              >
              > Thanks & Regards
              > Tarun
              

Maybe you are looking for