Define User ID Session Variable

I created a login page to authenticate users. The user enters
their email and password to login. At login, I would also like to
select a user id from the same table the email and password are
stored in. How can I add a session variable for the user id?
Here is the code created by Dreamweaver:

Are these functions on the same page? Will you be using this
variable on
other pages?
What you have described should work fine. Can you test it by
placing -
<?php echo "user id = " . $_SESSION['User_ID'];exit();
?>
immediately after your assignment code?
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"chris.cavage" <[email protected]> wrote in
message
news:gipmc7$ifd$[email protected]..
> After logging into my site, I need to have the User_ID
from the mysql
> table be
> saved as another session variable so I can reference the
user later.
>
> I added this to my page:
>
> <?php $_SESSION['User_ID'] =
$row_Recordset1['User_ID'] ?>
>
> My first recordset is table1 (has member information in
it).
>
> I then created a recordset from table2 (has the user_id
and financial info
> there): recordset2 filters the field "User_ID" based on
the session
> variable,
> "User_ID".
>
> I am then trying to insert information from that
recordset, but nothing
> happens.
>
> I did start the session at the top of the page. What can
I do
> differently?
>

Similar Messages

  • 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')

  • Internal LDAP Session Variable Population

    All,
    I can find plenty of documentation on how to populate a session varible from an external LDAP server. How do you populate a session variable from the internal LDAP server? I can't find documentation on this anywhere.
    Thanks in Advance,
    Josh

    Turribeach,
    In my .RPD I am trying to populate some of the system session variables, such as 'USER', 'DISPLAYNAME', 'GROUP', etc. from the out of the box, internal to Weblogic, DefaultAuthenticator, LDAP. I have found numerous blogs on how to connect to an external LDAP for authentication, at which point one can populate the system session variables from the external LDAP in an session variable initialization block. I can't find any documentation/blogs on how to use the internal LDAP to populate such system session variables. Any help will be greatly appreciated.
    I did find the system function 'user()' returns the user currently logged in, so that's a bit of a temporary workaround for the 'USER' system session variable.
    Thanks,
    Josh

  • Defining a recordset, sessions and session_start()

    It took me a long time to work out why a recordset defined using a session variable did not function.
    I finally decided that the session_start() command was not being inserted by the recordset creation procedure.
    Working out just where to put it in the code was not as simple as I thought.
    Initially I placed it after the include files, but that would not work.
    I eventually put it in the recordset creation code as follows:
    $colname_eventset = "-1";
    session_start();
    if (isset($_SESSION['event_sess'])) {
      $colname_eventset = $_SESSION['event_sess'];
    mysql_select_db($database_dummyread, $dummyread);
    $query_eventset = sprintf("SELECT * FROM events WHERE event_index = %s", GetSQLValueString($colname_eventset, "int"));
    $eventset = mysql_query($query_eventset, $dummyread) or die(mysql_error());
    $row_eventset = mysql_fetch_assoc($eventset);
    $totalRows_eventset = mysql_num_rows($eventset);
    This works fine, and as there is no output to the browser at this point, there is no error message "headers already sent". There may bve better locations
    I would have thought that any recordset defined using a session variable would have included the session_start() command in the code that it generated but apparently it does not.
    For the record, most of the help topics on session variables in Dreamweaver help refer to a no longer supported version (Ultradev) but at least one file is current: http://kb2.adobe.com/cps/165/tn_16563.html
    There may be others.

    Hi,
    If you are looking for something like global method it is not possible. But you can create a function module in SE37 and you can use the same wherever you want.
    Regards
    Githen

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

  • System session variable USER

    Hi,
    i have setup-ed the action links and used the USER variable for the EBS secuirty context init block as this
    EBS_RESP_ID
    EBS_RESP_APPL_ID
    EBS_SEC_GROUP_ID
    EBS_RESP_NAME
    EBS_USER_ID
    EBS_EMPLOYEE_ID
    USER
    Now for the sso configuration in the RPD i need to use the USER variable again as per the document (section A.1.1 )http://docs.oracle.com/cd/E14571_01/bi.1111/e10543/legacy.htm#BABFJEJF
    "To set up LDAP authentication:
    Create an LDAP Server as follows:
    Select Manage then Identity in the Oracle BI Administration Tool to launch the Security Manager.
    Select Directory Servers from the left pane in Security Manager.
    Right-click in the right pane in Security Manager and select New LDAP Server. The LDAP Server dialog is displayed.
    Create the LDAP server by completing the fields.
    Create an LDAP initialization block and associate it with an LDAP server. For more information. see "Creating Initialization Blocks" in Oracle Fusion Middleware Metadata Repository Builder's Guide for Oracle Business Intelligence Enterprise Edition.
    Define a system variable named *USER* and map the USER variable to an LDAP attribute (uid or sAMAccountName)."
    So how can i use the same user variable and assign it to LDAP init block as well the EBS security context init block.
    can you provide your valuable inputs here.

    Referencing GROUP session variable in initialization blocks for different types of authentication
    http://108obiee.blogspot.com/2009/10/referencing-group-session-variable-in.html
    Users are assigned to multiple groups from external table with semicolons, see example two and three from the post.
    Regards
    Goran
    http://108obiee.blogspot.com

  • ColdFusion 11 Throws Error Session Variable Undefined, When in fact it is Defined as shown by CFDump.

    I've been having a particularly annoying error with ColdFusion 11, and unable to track down the source of this problem.
    Basically There are a few variables defined in the session scope we check with isdefined a few lines above to make sure they are defined. Subsequent lines may or may not throw a #variablename# is undefined on random lines.
    What can I do to fix this issue? Is this a known bug?

    I am doing isDefined checks for relevant variables when neccessary. The problem is not that the code errors out undefined ... it's that the variable is actually defined and errors out undefined.
    As a simplified example;
    Login.cfm Form supplies form.username and form.password to login_action.cfm then redirects to index.cfm after succesful LDAP authentication. I will not include all lines as it would be too long.
    Login_action.cfm
    <cfinclude template="ldap.cfm">
    <!--- LDAP login code goes here; checks if credential's supplied are valid and sets variable #logged_in# ... --->
    <cftry>
        <cfif isdefined("logged_in") and logged_in>
            <!--- Create Session User Structure and Default Profile --->
            <cfset session.user=StructNew()>
            <cfset session.user.username=form.username>
            <cfset session.user.firstname="">
            <cfset session.user.surname="">
            <cfset session.user.email="">
            <!--- Pull in additional Details --->
            <cfquery name="qDetails" datasource="userdetails">
            SELECT firstname,surname,email FROM Profiles
            WHERE username = '#session.user.username#'
            </cfquery>
            <cfif isdefined("qDetails") and qDetails.recordcount>
                <cfoutput query="qDetails">
                <cfset session.user.firstname ="#qDetails.firstname#">
                <cfset session.user.surname="#qDetails.surname#">
                <cfset session.user.email="#qDetails.email#">
                </cfouput>
            </cfif>
        <cfelse>
            <!--- Throw Error back to login page --->
            <cfthrow message="1" type="Custom_Security" ErrorCode="Fail">
        </cfif>
        <cfcatch type="any">
            <!--- Throw Error back to login page --->
            <cfthrow message="2" type="Custom_Security" ErrorCode="Fail">
        </cfcatch>
    </cftry>
    <!--- Redirect User to login page after Successful Login --->
    <cflocation url="index.cfm">
    Index.cfm
    <!--- At Top of Index session.user.email always exists, in the event it is undefined it will be set to "" --->
    <cfparam name="session.user.email" default="">
    <!--- Lots of lines of code above here build HTML page etc <cfoutput> references to #session.user.email# and other session vars --->
    <!--- Example pull some more information this line may or may not error... --->
    <cfquery name="qUserInformation" datasource="userdetails">
    SELECT * FROM Information
    WHERE user_email = '#session.user.email#'
    ORDER BY SomeOtherColumn
    </CFQUERY>
    <!--- Example point where a session error can be generated less than 2 lines above it has just finished getting information using session.user.email --->
    <cfquery name="qUserGroups" datasource="userdetails">
    SELECT * FROM Groups
    WHERE user_email = '#session.user.email#'
    ORDER BY SomeColumn
    </CFQUERY>
    <!--- Some other common examples require cfscript - and throw errors; above lines may not ... --->
    <cfscript>
    oHomePage=CreateObject("component","site_components.homepage");
    qNews=oHomePage.getNews("#session.user.category#");
    </cfscript>
    <!--- More lines to do with HTML Footer etc <cfoutput> more stuff --->
    in the wwwroot the Application.cfm handles all errors generated during rendering of the page, which includes generating a cfdump of the session scope.
    When I get the Error Log I can see in the cfcatch cfdump the error... Element USER.EMAIL UnDefined in SESSION.
    struct
    Browser
    Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36
    DateTime
    {ts '2014-09-28 11:38:48'}
    Diagnostics
    Element USER.EMAIL is undefined in SESSION. <br>The error occurred on line 15.
    However when I check the SESSION scope which is also dumped ... It is defined!
    struct
    user
    struct
    COLOR
    cccccc
    EMAIL
    [email protected]
    FIRSTNAME
    Example
    SURNAME
    Surname
    EXAMPLE1
    1
    TEMPLATE
    template14
    TEMPLATE_DETAILS
    0
    What is causing this strange and irratic behaviour? The problem is so far I cannot replicate the issue. It is intermittant. The issue only started after upgrading to ColdFusion 11. This code has worked flawlessly for years on CF8.

  • SESSION VARIABLES : HOW TO TEST FOR MULTIPLE USERS

    I have a username session variable set up on a localhost testing envirnoment.
    This works fine for one user, but when I open another occurence of the browser (or just another tab) to test for multiple users the system overwrites the session variable with the last username input.
    So the question is:
             Why doesn't dreamweaver hold an instance of the session variable for each browser session? and if not what are your suggestions?
    Thanks
    Adam.

    Thanks for that.
    After scouring the internet I found the only way of running 2 instances of firefox  without them sharing the session variables is to create 2 new firefox profiles in windows + set the MOZ_NO_REMOTE environment variable.
    Internet explorer is much easier as it has a 'new session' option in the file menu, but seems to have more trouble displaying tables correctly.
    Hope this helps anyone with a similar problem.

  • Creating filtered view on the physical layer ussing session variable USER

    Hi:
    I´m creating a view on the physical layer, the view needs to be created dynamically. So depending on the user (using the session variable USER) the view is created with the data a particular user is able to see.
    Fisrt I imported the table and changed it´s properties to be created through a "Select Statement" so i don´t needed to change the mapping on the bussiness model layer.
    The consistency check was OK but i´m not able to see data in answers, even using the Administrator user. Have anyone tried to do this? Here is my query.
    Thanks
    A Garcia
    Select * from D_ESTRUCTURA_RH2 where Region_ID
    IN
    select distinct a.REGION_ID from APP_INDPERSONAL_DM.D_ESTRUCTURA_RH2 a
    inner join (
    select distinct b.REGION_ID from APP_INDPERSONAL_DM.D_ESTRUCTURA_RH2 b
    where exists (select 1 from APP_INDPERSONAL_DM.Autorizacion a, usuarios c
    where a.app_id = 1
    and a.usuario_id = c.Usuario_Id
    and UPPER(c.Nombre_Usuario)=UPPER(':USER')
    and a.miembro_id = 'REGION_ID'
    and a.operador = '='
    and (b.REGION_ID = (case when valor = 'Todo' then 0 else valor end) or valor='Todo'))
    ) seguridad
    on
    a. REGION_ID = seguridad.REGION_ID
    )

    whay not use the same filter in the content tab of the logical table source?
    check the physical sql sent to databse using web-admin-manage sessions-view log and see if there is any unexpected behavior. also run the same query in db and see iff you get the results in databse itself.

  • Prevent user from setting a parameter in url. Always use http session variable

    In my xsql page I want to prevent a user from seeing data that he is not allowed to see. I am thinking of implementing this by reading a http session variable (like userid=xxx) to be used in my query. I want to be absolutely sure that the userid variable cannot be set manually by the user, for instance by manipulating the url (like: mypage.xsql?userid=123). How can I do this?

    Sorry guys, already found it. Thanks to a reply from our lead-guru Muench on another post in this forum. Look here for the answer:
    http://download-west.oracle.com/otndoc/oracle9i/901_doc/appdev.901/a88894/adx10xsq.htm#1023490
    Search for "Understanding the Different Kinds of Parameters".

  • Can i use session variable VALUEOF(NQ_SESSION.USER) in write back report?

    Hi All,
    I have created a write back report and successfully inserted records into a table.
    Now i want to capture the user who has inserted in to the table.
    Till now i have given edit option to the users on USERNAME column.
    But now i want to capture the user automatically.
    when i user VALUEOF(NQ_SESSION.USER), i can capture the Logged in user in USERNAME col and the moment i execute the report it is throwing an error.
    What i observed is....
    In the advanced tab USERNAME col is changed to VALUEOF(NQ_SESSION.USER).
    is there any workaround for this?
    Thanks

    >>I have a session variable assigned to the ID#(auto
    number in access db) of messages posted.
    I not sure if I follow your in the description. I would
    assign the Record ID to the session variable.
    Place the Record id in the repeat region.
    Then you could assign that record id to a session variable
    when the button is click, capture the button click event. Then
    redirect to the EMPLOYEEMessageDELETE1.asp page, which will read in
    the session variable (record id) to be deleted.
    David Pearson

  • User Session Variable

    I'm new in php, I recently created login user name and
    password, is works great, and now I want to work on member update
    record.
    I'm trying to understand how to develop that using session
    variable in dreamweaver. I have two pages, the first page login.php
    where to login, and then redirect to second page member-profile.php
    which is member forms where to retrieve member information from
    mysql database using session variable and then update profile into
    the database.
    Does anyone know where i can learn sample of how to create
    update recorde using session variable! or can anyone explain how to
    write that in php code!
    please.. thanks.
    AM

    in the prompt for the user region or department, select SQL results for 'show' and 'report defaults' and write something like this:
    SELECT field exp FROM ... WHERE Employee.Alias = VALUEOF(NQ_SESSION.USER_ALIAS)
    this will give the right level of info and the user won't need to select it from the drop-down value.
    generally, when you select SQLresults for show, you get the SELECT and the FROM clause. Just add the WHERE clause and it should run properly.
    in the above example, I have assumed region/dept coming Employee dimension

  • Load more than one user groups to system session variable GROUP from table

    hi, I found that the value of the system session variable GROUP can be assigned by setting a sql in initialization blocks.
    however, if there are some users with more than one user group.
    can this be done by table driven (using sql in initialization blocks) ?
    thanks !!

    Referencing GROUP session variable in initialization blocks for different types of authentication
    http://108obiee.blogspot.com/2009/10/referencing-group-session-variable-in.html
    Users are assigned to multiple groups from external table with semicolons, see example two and three from the post.
    Regards
    Goran
    http://108obiee.blogspot.com

  • :USER and :GROUP session variables

    Hi,
    Please let me know the purpose of :USER and :GROUP variables. I have gone thru obiee docs but not understand clearly about these session variables.
    regards
    CK

    If you have to display a welcome message in a dashboard page with the user name, you can refer the USER session variable in the request. It will automatically get substituted with the log on name of the user
    Also you can use these variables in Authentication, authorization and data filters.
    Regards,
    Dpka

  • Use of session variable to retrieve user language

    Hi,
    I'm converting some ASP code to JSP and I'm having a problem concerning session variables, in ASP I had something like this
    (first.asp)
    <td align="center" width=145px><%=getLabel(1)%>
    and in second.asp
    dim Label(3,2)
    function GetLabel(ndx)
    GetLabel = Label(ndx, Session("Language"))
    end function
    clang_PT = 1 ' Portuguese
    clang_EN = 2 ' English
    Label(0,clang_PT) = "primeira"
    Label(1,clang_PT) = "Segunda"
    Label(0,clang_PT) = "first"
    Label(1,clang_PT) = "second"
    when trying to do the same thing in JSP
    (first.jsp)
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@include file="labels.jsp"%>
    <!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
    <%if (session.isNew()) {
    session.setAttribute("Language","1");
    }%>
    <%= getLabel(1)%>
    (labels.jsp)
    <%@ page language="java" import="java.util.*"%>
    <%@page pageEncoding="UTF-8"%>
    <%! String getlabel(int ndx){
    return label[ndx][session.getAttribute("Language")];
    String[][] label = new String[2][2];
    %>
    <%
    int clang_PT = 0; // Portugu�s
    int clang_EN = 1; // Ingl�s
    label[0][clang_PT] = "primeira";
    label[1][clang_PT] = "segunda";
    label[0][clang_EN] = "first";
    label[1][clang_EN] = "second";
    %>
    I get
    cannot find symbol symbol : variable session location: class org.apache.jsp.experiencia_jsp return label[ndx][session.getAttribute("Language")];
    ^
    and
    cannot find symbol : method getLabel(int)
    location: class org.apache.jsp.experiencia_jsp
    out.print( getLabel(1));
    Should I use a bean to store this kind of info?
    thanks, V

    right...
    actually, cuz doing this:
    <%!
    String getlabel(int ndx){
    int lang = Integer.parseInt((String)session.getAttribute("Language"));
    return label[ndx][lang];
    %>
    there's no session object... that creates a method in the class separate from the main JSP method. So you need to either pass the session object in, or just pass the attribute value..
    <%!
    String getlabel(int ndx, int lang){
    return label[ndx][lang];
    %>
    int lang = Integer.parseInt((String)session.getAttribute("Language"));
    String lable = getLabel(ndx, lang);

Maybe you are looking for