Session Variables Won't Persist

Hello all, I'm writing an app for work where a user logs in
to a system and then adds and removes entries from a database
through a web app. I use session variables to store both the user's
login ID and that user's permissions. I get through the login just
fine. After clicking on a link on the following page though ( an "a
href=" link) the session variables are not available to the
following page. I don't understand why the session variables aren't
persisting throughout the site. In my application.cfm I have
<cfapplication name="App" sessionmanagement="true"
sessiontimeout="#CreateTimeSpan(0, 1, 0, 0)#"> Any help with
this would be greatly appreciated.

Ah good. That's precisely what I was touching on when I asked
you:
- Are you accessing the same site with different domains, or
sub-domains? Ex: www.mysite.com, www2.mysite.com
Changing domains, and/or how you address the site itself will
always throw a curve-ball to your session vars. Session vars seem
to be related to two things:
1) The site's "domain" address (servername, www.mysite.com,
www2.mysite.com, localhost, etc)
2) The application "name" (see "name" attribute of your
cfapplication tag)
If either of the above two things change, you *can* lose your
session.
If you wanted to have a session persist across different
domains however, it is important to note that you CAN in fact do
that. You simply need to manually pass the CFID and CFTOKEN in the
URL at the exact point you cross from one domain to another.
(Assuming of course that both domains point to the same CF
application on the same server or cluster, and using the same
application "name")
The CF-server will detect those CFID and CFTOKEN vars in the
URL, and pull the correct session that you had from the previous
domain. Once you're "in" the second domain, you no longer need to
pass these tokens via the URL. However, if you wanted to cross BACK
to the original domain, you should once again pass those CFID and
CFTOKEN vars in the URL at the exact point you switch domains.
Anyways, I'm glad you worked it out. I wanted to add this
additional bit of explanation in case anyone else is reading, or
someone stumbles across this a year from now.

Similar Messages

  • 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.

  • Dates Format in Promts using Session Variables

    Hi Experts,
    I have an issue in controlling date format in prompts using session variable which I am using to set default value.
    By default date format is timestamp E.g '2010-12-19 12:00:00 AM'.
    As per requriement(s) I customized the date format in Reports as 19-Dec-2010 and I saved it as "System Wide Default for <Date Column Name> "
    So, I got desired format in Reports and Date Prompts.
    Now, I need to set a default value in Date Prompt. So, in RPD I created a Session Variable which returned me date in
    DD-MON-YYYY format. Using follwing SQL :
    SELECT REPLACE(CONVERT(VARCHAR(11), Getdate (), 106), ' ', '-') AS [DD-Mon-YYYY]
    But in reports takes this value as string and not Datetime. So i got an error message.
    A datetime value was expected (received "19-Dec-2010").
    If i do not use above SQL to CONVERT date then default date in prompt get displayed as timestamp format and give me desired results but Formatting looks very odd in prompt
    Is this a way so I can persist the [DD-Mon-YYYY] Formatting for default value which comes using variable and still run the report.
    Above problem also exist vice versa that is if i SET that session variable and pass the datetime value to server. But there i guess I can use ToDate or some Casting in RPD column expression to handle that. Tell me if i am right ?
    Thanks
    Saurabh

    That almost works. I had to adjust the syntax to the following...and then there are other issues doing this.
    select cust_no, name,'@{session.currentUser}' from customersMy write-back SQL is this:
    UPDATE customers SET NAME='@{c1}',LAST_EDITED_BY='@{c2}' WHERE CUST_NO=@{c0}But I don't want to display the cust_no column to the user. So I hide it in the UI. But if I do that I get the below error during write-back. Apparently sometimes when you hide a column on a direct query (numeric maybe?) the value doesn't transfer over to the write-back. If that's the case, this won't work for me. Hmm...
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43093] An error occurred while processing the EXECUTE PHYSICAL statement. [nQSError: 17001] Oracle Error code: 936, message: ORA-00936: missing expression at OCI call OCIStmtExecute: UPDATE customers SET NAME='Wyatt Donnely',LAST_EDITED_BY='Administrator' WHERE CUST_NO= . [nQSError: 17011] SQL statement execution failed. (HY000)
    SQL Issued: EXECUTE PHYSICAL CONNECTION POOL dev1 UPDATE customers SET NAME='Wyatt Donnely',LAST_EDITED_BY='Administrator' WHERE CUST_NO=

  • Session variables being lost

    In my onApplicationStart method (which should tell you I'm
    using an Application.cfC, not cfM), I have a cfif loop that passes
    a value to a custom tag and returns a form variable. I'm then
    reassigning that variable to a session variable. In IE, this works
    just fine; in Firefox, though, the session variable is NOT being
    set.
    What might be causing this, and is there a workaround?

    The issue referred to an external CF custom tag, which called
    another demo application to set a testing user. However, after
    further testing, I realize that demo app won't function properly
    with this application, so I've removed it.
    Authentication is being set by an LDAP query; this
    application that I am working on is going to be a sub-application
    of a larger application, and the authenticated user is being set as
    a session variable as well (I think...). However, I'm creating a
    new session variable for this application, and simply passing the
    authenticated user into my app (the outer app uses the variable
    auth_user; I'm using the variable authuser, so there is no name
    conflict).
    Again, it is IE that is not persisting the session. Firefox
    is doing so. I have looked in the advanced settings for IE, and
    there is nothing about persisting session variables to check or
    uncheck. Also, this application will probably be used mostly by
    users using IE 6 with default settings, so I'm going to need to
    find a workaround for IE.
    Your help is most appreciated.

  • Trying to move a list of form variables to session variables of the same name

    I am trying to move a list of form variables to session variables of the same name and I am having a lot of trouble.
    I have never had to post of this forum with a language question in all the 10 years I have been using ColdFusion. I was a qa Engineer @ Allaire/Macromedia back when it was going from one to the other. I have a pretty good grasp of the language.
    I have software that runs off a list. The fieldnames are variable and stored off in an array. It's survey software that runs off a "meta file". In this example; I have the number of fields in the survey set to 12 in the "metafile". I have each field declared in that file in array Session.SurveyField[1] and the above loop works fine. I include this "metafile" at the start of the process.
    I cfloop around a struct and it works wherever I have needed to use it; such as here - writing to the database for example;
    <CFQUERY NAME="InsertRec" DATASOURCE="Survey">
    INSERT into #variables.SurveyTableName#
    (EntryTime
    <cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
    ,#Session.SurveyField[arrayindex]#
    </cfloop>
    <!--- EXAMPLE OF WHAT THE ABOVE GENERATES
    ,q01_name,q02_AcadTechORNA,q03_Water,q04_FirstAid,q05_CPR,q06_LifeGuard,q07_AED
    ,q08_ProjAdv,q09_Color,q10_SantaClaus,q11_Supervisor,q12_SupervisorOpinion --->
       VALUES
        ('#EntryTime#'
    <cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
    <cfset thisname = "Session." & Session.SurveyField[arrayindex]>
    ,'#evaluate(variables.thisname)#'
    </cfloop>
    <!--- EXAMPLE OF WHAT THE ABOVE GENERATES
    ,'#Session.q01_name#','#Session.q02_AcadTechORNA#','#Session.q03_Water#','#Session.q04_Fi rstAid#'
    ,'#Session.q05_CPR#','#Session.q06_LifeGuard#','#Session.q07_AED#','#Session.q08_ProjAdv# ',
    ,'#Session.q09_Color#','#Session.q10_SantaClaus#','#Session.q11_Supervisor#','#Session.q1 2_SupervisorOpinion#' --->
    </CFQUERY>
    NOW HERE'S THE PROBLEM: I am running into trouble when trying to move the form variables to session variables of the same name. It is the only part of the software that I still need the datanames hard coded and that is a roadblock for me.
    <cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
    <cfset thissessionfield = "Session." & Session.SurveyField[arrayindex]>
    <cfset thisformfield = "Form." & Session.SurveyField[arrayindex]>
    <cfset #thissessionfield# = #evaluate(thisformfield)#>
    </cfloop>
    I have tried it with or without the "evaluate"; same result. It doesn't give an error; it just ignores them (session variables look as such in the next page in the chain)
    q01_name=
    q02_acadtechorna=
    q03_water=
    q04_firstaid=
    q05_cpr=
    q06_lifeguard=
    q07_aed=
    q08_projadv=
    q09_color=
    q10_santaclaus=
    q11_supervisor=
    q12_supervisoropinion=
    Note: they exist because I CFPARAM them in a loop like the above at the start of the procedure) - and this works just fine!
    <cflock scope="Session" type="EXCLUSIVE" timeout="30">
    <cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
    <cfset dataname = "Session." & Session.SurveyField[arrayindex]>
    <cfparam name="#variables.dataname#" default="">
    </cfloop>
    </cflock>
    I EVEN tried exploiting the Form.Fieldnames list using CFLoop over the list and the same sort of logic within and it still gives me nothing....
    Here's the FORM.FIELDNAMES value
    "Q01_NAME,Q02_ACADTECHORNA,Q03_WATER,Q04_FIRSTAID,Q05_CPR,Q06_LIFEGUARD,Q07_AED,Q08_PROJAD V,Q09_COLOR,
    Q10_SANTACLAUS,Q11_SUPERVISOR,Q12_SUPERVISOROPINION"
    Here's the logic; SAME RESULT - The session variables don't get set.
    <cfoutput>
    <cfloop list="#Form.FieldNames#" index="thisfield">
    <!--- <br>#thisfield# --->
    <cfscript>
    thisSESSIONfield = "Session." & thisfield;
    thisFORMfield = "Form." & thisfield;
    #thisSESSIONfield# = #thisFORMfield#;
    </cfscript>
    </cfloop>
    </cfoutput>
    The CFPARAM in a loop with variable output name works just fine; so does the post (which I included above) as does the SQL Create, Param Form Variables, Param Session Variables, etc.
    THIS even works for moving BLANK to each session variable, to zero them all out at the end of the process;
    <cflock scope="Session" type="EXCLUSIVE" timeout="30">
    <cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
    <cfset thislocalfield = Session.SurveyField[arrayindex]>
    <cfscript>
    thissessionfield = "Session." & thislocalfield;
    </cfscript>
    <cfset #thissessionfield# = "">
    </cfloop>
    </cflock>
    Expanding on that code, you would think this would work, but it doesn't;
    <cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
    <cfset thislocalfield = Session.SurveyField[arrayindex]>
    <cfscript>
    thissessionfield = "Session." & thislocalfield;
    thisformfield = "Form." & thislocalfield;
    </cfscript>
    <!--- debug --->
    <!--- <cfoutput>#thissessionfield# = "#evaluate(thisformfield)#"</cfoutput><br> --->
    <cfoutput>
    <cfset #thissessionfield# = "#evaluate(thisformfield)#">
    </cfoutput>
    </cfloop>
    And see that debug code in the middle? To add insult to injury... When I uncomment that it shows me this. So it certainly looks like this should work....
    Session.q01_name = "Me"
    Session.q02_AcadTechORNA = "N/A"
    Session.q03_Water = "Yes (certificate expired)"
    Session.q04_FirstAid = "Yes (certificate is current)"
    Session.q05_CPR = "No"
    Session.q06_LifeGuard = "Yes (certificate expired)"
    Session.q07_AED = "Yes (certificate expired)"
    Session.q08_ProjAdv = "Yes (certificate expired)"
    Session.q09_Color = "Gray"
    Session.q10_SantaClaus = "Yes"
    Session.q11_Supervisor = "Da Boss"
    Session.q12_SupervisorOpinion = "Not a bad thing"
    There must be some simpler way to do this. This way won't work against all odds even though it seems so much like it should.
    So I end up having to hardcode it; still looking for an automated way to set these #@%$*@!## session variables over the list from the form variables of the same @#@!$#%$%# name. Do I sound frustrated???
    No matter what I do, if I don't HARDCODE like this;
    <cfset Session.q01_name = Form.q01_name>
    <cfset Session.q02_AcadTechORNA = Form.q02_AcadTechORNA>
    <cfset Session.q03_Water = Form.q03_Water>
    <cfset Session.q04_FirstAid = Form.q04_FirstAid>
    <cfset Session.q05_CPR = Form.q05_CPR>
    <cfset Session.q06_LifeGuard = Form.q06_LifeGuard>
    <cfset Session.q07_AED = Form.q07_AED>
    <cfset Session.q08_ProjAdv = Form.q08_ProjAdv>
    <cfset Session.q09_Color = Form.q09_Color>
    <cfset Session.q10_SantaClaus = Form.q10_SantaClaus>
    <cfset Session.q11_Supervisor = Form.q11_Supervisor>
    <cfset Session.q12_SupervisorOpinion = Form.q12_SupervisorOpinion>
    I always get this from my next page because the session variables are empty;
    You must answer question 1.
    You must answer question 2.
    You must answer question 3.
    You must answer question 4.
    You must answer question 5.
    You must answer question 6.
    You must answer question 7.
    You must answer question 8.
    You must answer question 9.
    You must answer question 10.
    I tried duplicate as well, but I can not get the above to work...
    Can anyone help me do this thing that one would think is simple????

    I think if you use structure array syntax you should get the results you want.
    <cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
          <cfset session[Session.SurveyField[arrayindex]] = Form[Session.SurveyField[arrayindex]]>
    </cfloop>
    Or probably even easier.
    <cfset session = duplicate(form)>

  • Null session variable

    Ok, i have a problem which is really annoying me and i have been stuck on for a while. I am developing a website for my brothers company and am really stuck for time for the launch date. I developed a website last year which worked fine and i am re using the code from that. I am setting a session variable "sessEmail" when the user logs in and want to retrieve it when they go to add a produt to their cart. Here is my code
    String Email = request.getParameter("txtEmail");
    String Password = request.getParameter("txtPassword");
    session.setAttribute("sessEmail",Email);
    Object o = session.getAttribute("sessEmail");
    String s = o.toString();
    out.print(s);
    I am just printing out the "sessEmail" to make sure it is working. It works fine when i try and retrieve the session variable on the same page were i set it but on a seperate page it wont work. It is returning a null pointer exception because the session variable has no value. It is occuring when i try to convert an object to a string.
    Any help would be much appreciated as i am stuck for time.
    Cheers

    Ok the first question to be asked is why it is null?
    The most obvious answer is that you have cookies disabled, and are not using URL rewriting.
    To retain the session, the server issues a "Session Cookie" with your jsessionid in it. If you have cookies switched off on your browser, it won't retain the session.
    To confirm this print out session.getId() on your pages. If it continually changes, you aren't keeping your session. If it remains the same, you HAVE got a session, and need to check why you are putting a null value there.
    To retain session, you need to run every link/url that gets printed to your page through the method response.encodeURL() which will add on the session id manually if cookies are not supported.
    Hope this helps,
    evnafets

  • Page Specific Persistence using Session Variables

    Hi, I have read a lot about using session variables to persist the ReportDocument object across page loads.  This works fine if you have just one page open with one report.  The problem I am having is I have a web application that makes 30 or 40 different reports available to the user.  To simplify the code and make it easier to add new reports I have developed a single template aspx page that can be used to view any of the reports.
    My problem is that if the user opens 2 different reports in 2 separate tabs in the browser then the session variable persistence doesn't work because the session variable is available to both tabs.
    Is there a way to persist the ReportDocument object which is 'page' specific.
    Thanks

    Your best option is likely to have something that makes the session variable names unique.  I've done such things as putting the current datetime in the url as a querystring parameter and appending that to the variable name.  On each postback that querystring should persist.
    You might be able to use the reportclientdocument object and serialize the report and persist through view state, haven't tried this with inproc ras though.  A sample that uses the ras sdk can be found [here|http://wiki.sdn.sap.com/wiki/display/BOBJ/NETRASSDK+Samples]

  • Session variables dropping

    I've been having this problem for a long time so I thought
    I'd post again and maybe get a hit this time.
    We run off windows cfmx 7.x now fully patched, prior to that
    we were on cfmx 6.x. We use session management only. Many times on
    a new page hit the user loses about half of their session variables
    up to all of them. Typically we have them test on the same machine
    using different browsers. 99% of the time switching from IE to
    firefox solves the problem, most of the users have had IE 6.x.
    I experienced this problem myself for about 4 months time and
    I could reproduce it daily when neccessary by simply opening a new
    window to our application and the session information would persist
    to the new window but the parent window would receive a new cfid
    and lose all session information. New windows aren't the only
    issue, we see a lot of lost session variables in one click, same
    window, functionality. I've had hooks in place to test if the
    domain was different on page hits removing the www or something but
    so far have not found anything there. Each time a new CFID is being
    issued and they are losing the original. We attempted to put CFID's
    in the URL at all times but that leads to other issues and didn't
    solve the problem for us anyhow.
    This has been a serious issue for awhile and browsing these
    forums I see others are experiencing it to some extent too. I'm
    wondiner if anyone has any tips or can confirm the CF Admin/app.cfc
    setup you use if you're not seeing any problems like this.

    right... response.sendRedirect(). sendRedirect works by sending a repsonse to the browser with a location header. The browser sees that header and makes a new, separate request to the new location. It's no different then typing the location in the location bar in the browser or clicking a link.
    But that doesn't matter. If you have 2 web applications (aka 2 servlet contexts) on the server, they are not going to share sessions between them. So the first page is working off one session in one context with some ID. Then the redirect sends it to another page in a different context. That session ID is not valid in that 2nd context, so a new session is created like it was a first time user. And if you redirect back, you may not get the same session for the first context, unless the session ID cookie defines the path as well (I'm not sure offhand).
    The "application" object is the servlet context, specifically a javax.servlet.ServletContext object (or implementation of the interface, technically). Nothing is shared between contexts.
    Now, you can always share things in one way or another. Store things in a database or in files. Use a messaging system like SOAP or JMS. Maybe the server allows for contexts to access each other (they aren't shared in that case, just that you can get a named context and read what's stored in it).
    Or don't have your separate contexts, use subdirectories in the same context.

  • Filter recordset with session variable

    This has never happened to me before, but for some reason, my
    recordset that drives a dynamic table won't filter results based on
    a session variable. I know session variables are working because I
    have the session variable echo on the page (dragged-n-dropped my
    session variable from the Bindings panel to my page), and that
    works fine. So why can't I filter my recordset with the same
    session variable??? What's going on?
    PS: I've attached my result page's code to this
    message.

    Gabe the Animator wrote:
    > <?php require_once('Connections/sales.php'); ?>
    > <?php
    > if (!function_exists("GetSQLValueString")) {
    > function GetSQLValueString($theValue, $theType,
    $theDefinedValue = "",
    > $theNotDefinedValue = "")
    > {
    > $theValue = get_magic_quotes_gpc() ?
    stripslashes($theValue) : $theValue;
    >
    > $theValue = function_exists("mysql_real_escape_string")
    > mysql_real_escape_string($theValue) :
    mysql_escape_string($theValue);
    >
    > switch ($theType) {
    > case "text":
    > $theValue = ($theValue != "") ? "'" . $theValue . "'" :
    "NULL";
    > break;
    > case "long":
    > case "int":
    > $theValue = ($theValue != "") ? intval($theValue) :
    "NULL";
    > break;
    > case "double":
    > $theValue = ($theValue != "") ? "'" .
    doubleval($theValue) . "'" :
    > "NULL";
    > break;
    > case "date":
    > $theValue = ($theValue != "") ? "'" . $theValue . "'" :
    "NULL";
    > break;
    > case "defined":
    > $theValue = ($theValue != "") ? $theDefinedValue :
    $theNotDefinedValue;
    > break;
    > }
    > return $theValue;
    > }
    > }
    >
    > $colname_rsSales = "-1";
    > if (isset($_SESSION['state'])) {
    > $colname_rsSales = $_SESSION['state'];
    > }
    > mysql_select_db($database_sales, $sales);
    > $query_rsSales = sprintf("SELECT * FROM sales WHERE city
    = %s",
    > GetSQLValueString($colname_rsSales, "text"));
    > $rsSales = mysql_query($query_rsSales, $sales) or
    die(mysql_error());
    > $row_rsSales = mysql_fetch_assoc($rsSales);
    > $totalRows_rsSales = mysql_num_rows($rsSales);
    >
    > session_start(); ?>
    The issue is that PHP doesn't "work" with session values
    until the session has started, and that must be done on each page,
    and must be done in the code *above* any reference to a session
    variable. The code you posted has the session_start() after it
    tries to use the session value ito filter the recordset. So move
    this last line of code ( session_start(); ) above $colnam_rsSales =
    "-1". Better yet, use:
    if(!session_id()){
    session_start();
    To prevent some versions of PHP from generating a
    warning/notice if you've called session_start() on the page already
    and you call it again.
    Danilo Celic
    | Extending Knowledge Daily :
    http://CommunityMX.com/
    | Adobe Community Expert

  • Filtering recordset with session variable

    This has never happened to me before, but for some reason, my
    recordset that drives a dynamic table won't filter results based on
    a session variable. I know session variables are working because I
    have the session variable echo on the page (dragged-n-dropped my
    session variable from the Bindings panel to my page), and that
    works fine. So why can't I filter my recordset with the same
    session variable??? What's going on?
    PS: I've attached my result page's code to this
    message.

    Actually, problem solved. I moved " session_start()" above
    "$colname_rsSales = "-1" ", which did the trick.

  • Session Variables Randomly  Lost between Pages

    My web page uses a session to keep track of who logged in.
    What I noticed is that the session variables stored appears and
    disappears randomly on different pages. The wierd thing is that my
    code is very simple.
    For the life of me I can not figure this out....

    I go through a hosting company and do not expect them to do
    any load balancing.
    What are sticky sessions?
    The cflocation tag also has the addtoken="yes" to it now and
    symptoms persist.
    I tested the case with
    sessiontimeout=#CreateTimeSpan(0,2,0,0)# instead of the
    sessiontimeout=#CreateTimeSpan(0,0,120,0)# and symptoms still
    persist.
    Any other suggestions? I think I ran into a wall
    here....

  • DISPLAYNAME session variable

    The documentation says that I can use the DISPLAYNAME session variable. However, in the server variable initialization block, it returns no value. In fact, it is not even recognized as a bind variable.
    For example,
    The query select ':USER' from dual returns
    Variable Value
    ==== ========
    mysessvar Administrator
    However, select ':DISPLAYNAME' from dual returns
    Variable Value
    ==== ========
    mysessvar :DISPLAYNAME
    I have read other threads dealing with the GROUP session variable, so it seems like this should be possible. However, I cannot get it to work. I am using OBIEE version 10.3.3.2. Thanks.

    Sorry. Yes, usually the best thing to do is state your objective, rather than your method. I am using SSO, but I want to have the ability to filter records based on the user logging in. Here is one way I thought of doing this.
    What I need to do is filter records based on a particular ID. Let's say my report table looks like this:
    RID UID Amount
    === === =====
    1 1 10
    2 2 15
    3 1 20
    I also have a table mapping username to UID, let's call it USERS.
    UID Username
    == ========
    1 Joe
    2 Bob
    We have set up OBI to use SSO and cookies. We will authenticate the user and then redirect to OBI. However, in OBI, I only want to show the records related to the user logging in. So, if Joe logs in, I only want to show records with RID =1,3. If Bob logs in, I only want to show records with RID=2.
    Now, if I was to create 1 named user in OBI for each user in USERS, I could use an init block to query the USERS table, get the UID and set it to a session variable. I could then use this session variable to filter my records. However, even though we won't have that many users, I don't want to do it manually. I want to create one OBI user that has access to the report. To filter records, my thought was to set the DISPLAYNAME using a cookie and then use the DISPLAYNAME to retrieve the UID.
    To answer the question asked by Turribeach, OBI is only looking at users defined in the rpd. We are using SSO, but OBI is not using external authentication.
    To summarize, I am using SSO, but I want to have the ability to filter records based on the user logging in. I just want to know the best way of doing that. Thanks!

  • How do i filter recordsets using session variable???  Please help this is driving me mad...!!

    I am having the same problem as user "Gabe the animator" in a post sent in 2007.
    "my recordset that drives a dynamic table won't filter results based on a session variable. I know session variables are working because I have the session variable echo on the page (dragged-n-dropped my session variable from the Bindings panel to my page), and that works fine. So why can't I filter my recordset with the same session variable???"
    here is the code:
    <?php require_once('Connections/mockconn.php'); ?>
    <?php
    session_start();
    ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    if(!session_id()){
    session_start();
    $colname_info = "-1";
    if (isset($_SESSION['email'])) {
      $colname_info = $_SESSION['email'];
    mysql_select_db($database_mockconn, $mockconn);
    $query_info = sprintf("SELECT name, last_name, email, password FROM registration WHERE email = %s", GetSQLValueString($colname_info, "text"));
    $info = mysql_query($query_info, $mockconn) or die(mysql_error());
    $row_info = mysql_fetch_assoc($info);
    $totalRows_info = mysql_num_rows($info);
    ?>
    <!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>home</title>
    </head>
    <body>
    <div id="info">hello <?php echo $row_info['']; ?></div>
    <?php
    if (isset($_SESSION['email'])) {
              echo 'your email: '.' '. $_SESSION['email'] .' '.'good job';}
                        ?>
    </body>
    </html>
    PLEASE PLEASE HELP.... I have been at this for day's...
    how do I get the record set to filter based on the value of the session variable

    Sorry I forgot to mension the error I am getting?
    ( ! ) Notice: Undefined index: in C:\wamp\www\mock\home.php on line 59
    Call Stack
    Time
    Memory
    Function
    Location
    1
    0.0093
    389024
    {main}( )
    ..\home.php:0
    Why is this error coming up?

  • Using session variables in Flex 2

    I'm not sure if this is the correct place for this
    topic...but the Flex 2 upgrade/migration forum didn't seem too
    lively. So let me set up my situation and then pose the question.
    In Flex 1.5, I accessed the session servlet using:
    <mx:RemoteObject source="servlet" id="servlet"/>
    This allowed me to store session variables such as a user
    object:
    var u:User = new User();
    servlet.session("set", "user", u);
    This allowed me to access these variables from another Flex
    app:
    var user:User;
    servlet.session("get", "user");
    How would I go about doing this in Flex 2.0? Thanks to those
    who can help.

    That almost works. I had to adjust the syntax to the following...and then there are other issues doing this.
    select cust_no, name,'@{session.currentUser}' from customersMy write-back SQL is this:
    UPDATE customers SET NAME='@{c1}',LAST_EDITED_BY='@{c2}' WHERE CUST_NO=@{c0}But I don't want to display the cust_no column to the user. So I hide it in the UI. But if I do that I get the below error during write-back. Apparently sometimes when you hide a column on a direct query (numeric maybe?) the value doesn't transfer over to the write-back. If that's the case, this won't work for me. Hmm...
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43093] An error occurred while processing the EXECUTE PHYSICAL statement. [nQSError: 17001] Oracle Error code: 936, message: ORA-00936: missing expression at OCI call OCIStmtExecute: UPDATE customers SET NAME='Wyatt Donnely',LAST_EDITED_BY='Administrator' WHERE CUST_NO= . [nQSError: 17011] SQL statement execution failed. (HY000)
    SQL Issued: EXECUTE PHYSICAL CONNECTION POOL dev1 UPDATE customers SET NAME='Wyatt Donnely',LAST_EDITED_BY='Administrator' WHERE CUST_NO=

  • OBIEE 11g Session variables

    Would anyone know who to setup the USER session variables in the RPD for OBIEE 11g?
    The security setup we have is LDAP Authentication & Default authenticators in Weblogic. Is there a way to retrieve this in the RPD or in answers?
    Lastly, would proxy (act as) functionality configuration differ from 10g because of the above?
    Thanks.

    All,
    Use VALUEOF(NQ_SESSION.USER) whether you are in the front end or .RPD, :USER doesn't work anymore. Also, there is no need to wrap the syntax in quotes, if you do, it won't de-reference the variable.
    Thanks,
    Josh
    Edited by: JFuter on Mar 24, 2011 5:16 PM

Maybe you are looking for

  • Moderator please – I want the money back that BT o...

    Could a BT Forum Moderator please look into my account, contact the department currently handling my case, and arrange a refund for the money that BT owe me back, after overcharging my account for the last 3 months. After my original phonecall 7 WEEK

  • Question on Adobe Photoshop 5.0 for Mac

    I am using on my IMac (10.6.8 Snow Leopord) Aperture 3. I want to know  : 1. Can I download and use Abode Photoshop 5.0  Limited Edition  Windows / Mac  onto my IMac ? 2. Although this Abode program is ancient now, can it do certain things that Apert

  • Podcasts are "stuck"; keep getting the same podcasts no matter what

    Greetings, Gee, it seems the only problem I ever have with my iPhone is syncing. And it's started again. I have subscriptions to about 30 podcasts, about half of those are checked to sync with my iPhone. About a week or so ago, I would listen to a po

  • Having problems importing my .mov file.

    I am having problems importing several .mov files into iMovie. I also can't import .wmv files and I have been utterly confused. I know I have to convert the files but I don't want to pay for a program because I will only be converting 4 files. Please

  • How do you change PS Camera Raw dialog w/ Asian language to English

    I think I was moving too fast using Bridge and accidentally changed a setting. I opened a jpeg in Camera Raw within Bridge, made some corrections in Bridge Camera Raw, then clicked Done. Later, when I double clicked the corrected image in Bridge so t