Broken Session Problem

Having learned how to use sessions recently. I thought
eveything was going ok.
But for some reason the session is not working or the code
has been broken somehow.
I have not edited anything in the section where the session
info is.
What my session does is check if logged in = true and
displays the visitors username with welcome before the name.

The_FedEx_Guy wrote:
> I'm sorry. I have included the files below:
You seem to be doing things in a very roundabout way. Both
header.php
and login.php include db.php, and both of them call
session_start().
Also, your code to display the welcome message displays the
name only if
$_SESSION['logged'] is *not* true.
You don't need header.php at all. You simply need to create a
session
variable for the username at the same time as
$_SESSION['logged']:
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
$_SESSION['logged'] = true;
$_SESSION['sessFirstName'] = $_POST['username'];
Then later:
<div class="userWelcome"><?php {
echo 'Welcome '. $_SESSION["sessFirstName"];
} ?></div>
Note that the condition looks like this:
if ($_SESSION['logged'])
You had this:
if ($_SESSION['logged'] == "true")
That means: if $_SESSION['logged'] contains the string,
"true". However,
$_SESSION['logged'] doesn't contain a string; it's a Boolean
(true/false) variable.
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of
ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

Similar Messages

  • Java Session problem while sending mail(using javamail) using Pl/SQL

    Hello ...
    i am using Java stored procedure to send mail. but i'm getting java session problem. means only once i can execute that procedure
    pls any help.

    props.put("smtp.gmail.com",host);I doubt javamail recognizes the 'smtp.gmail.com' property. I think it expects 'mail.host'. Of course since it cannot find a specified howt it assumes by default localhost
    Please format your code when you post the next time, there is a nice 'code' button above the post area.
    Mike

  • Session problem in jsp application

    I face a session problem. I setting everything in a session and when pass back to a main page, the value is not display in the screen. But after refresh the value will display in the screen and this kind of problem only come out very few time and i dun knw how to solve this...
    Anyone here can give me some idea and suggestion or the way to solve this kind of problem!!!

    define "2 different clients"
    1) You have 2 different PCs and it's using the same session ID for both? I doubt this. I think the server is advanced enough not to use give a session ID that's already been created.
    2) You have 1 PC and are using IE or Netscape and using File > New Window to open a new window and connect again. This you can't fix without using only URL rewriting to manage session, because the different windows will share the same session cookies.

  • W3d with transparent textures will be broken transmission problems

    W3d with transparent textures will be broken transmission
    problems
    When the W3D models have Texture with alpha channel, It will
    be Crusher and Transmittance (Showing the bottom), If not alpha it
    will be normal! please tell me why,Thanks
    snap:
    have alpha channel:
    snap-alpha.JPG
    no alpha channel(normal):
    snap-no-alpha.JPG
    3d model Source file & W3D file:
    http://www.3dzone.cn/beijixiong.zip
    <---new

    As we have written you can get it to work. Just do one of the
    following.
    1. Make the model a complete mesh. no parts just stuck into
    others. Make sure vertecies are welded together properly etc.
    2. a) Separate the head,hat,hands etc b) group them together
    c) export (the exporter will combine them into one model again).
    3. a) Assign a non transparent texture to your model, b)
    select the polygons that needs transparency, c) assign the
    transparent texture to those polygons
    4. Outsource the importing of models to someone else.
    I used method 2 as I mentioned in an earlier post and got it
    to work, here is the result.
    Scarecrow
    with transparency working
    The url to report bugs to adobe was recently posted, use the
    search function.

  • Broken session

    I've got a problem when running my internet application on
    Oracle App. Server 1.0.2.2.1 in SSL mode. Clients are
    IE 5.0, 5.5 and 6.0. The application uses more instances
    of web browser at the same time (using the same session).
    In non-secure mode, everything is ok. In ssl mode, session
    is sometimes broken.

    I've got a problem when running my internet application on
    Oracle App. Server 1.0.2.2.1 in SSL mode. Clients are
    IE 5.0, 5.5 and 6.0. The application uses more instances
    of web browser at the same time (using the same session).
    In non-secure mode, everything is ok. In ssl mode, session
    is sometimes broken.

  • Session problem in a new window created by window.open()

    hello,
    I have a drugsearch.jsp page, I sessioned an durgCollection object on this jsp page using session.setAttribute("drugCollection",drugCollection);
    there is a link on this jsp which will call a javascript to open a new window .
    here is the javascript to open another new window:
    function openReportWindow()
    window.open("/drug/Report.jsp","report", "toolbar,scrollbars,width=800,height=800,left=100,top=10");
    but in the Report.jsp, I won't be able to get the same session object as in the calling jsp ( drugsearch.jsp) by calling session.getAttribute("drugCollection").
    if I change the link on drugsearch.jsp to link to the Report.jsp directly instead of opening a new window, then I can get the same session object from the Report.jsp.
    what's the problem? can someone give me an advice?
    thanks

    A session is assosiated with one client(browser).
    when you open a new browser, a new session is created. In order to have common place for both the browsers, try storing the data in the 'Servlet Context'

  • Session problem in ADF BC

    We have an application developed in Jdev 10.1.3.4 (JSP, Struts, ADF BC) and running on OAS. Now we have a big problem with session, hope somebody can help with some ideas.
    We set session time to 45 min in the web.xml. The problem is that sometimes some user work on a page with form,for instance performing some edit activity. If he/she leave the page open inactive for more than 45 minutes and come back from lunch, press the ’save’ button, the application would then commit the change to the wrong row in database, most probably the top row in the View Object(VO) instance. This is because the application module actually does a rollback when session expires, it loses all user data.(e.g. row currency in VO instance).
    To avoid saving wrong data to the wrong place, we implemented a session Filter(see att. Below: ApplicationSessionExpiryFilter.java) to catch session time-out and forward request to an error page alerting user that their session has expired due to long time of inactivity. The Filter works as it should but it gives another problem. If user already has one of our application page open for very long time and open another page in a new browser (e.g. click a link from an email), he/she will get session-expire error immediately in the new browser. I guess it is because the session in the first browser already expires and the newly opened the browser shares the same session with the first one. That is how browsers works, we can do nothing about it.
    But our users are of course not very happy about getting the session errors in a newly opened browser. So we tried implementing a heartbeat funtion in AJAX(see att. Below: Heartheat.html and Template.jsp) to keep the session alive until the page is closed. Basically what we do is adding an invisible div tag in every jsp page and invoke AJAX funtion to periodically update the div tag with a small html page. In this way, a request is being sent to the server every 5 minutes thus the session should be kept alive until the page/browser is closed.
    It sounds to us like a very logical solution but it doesn’t work very properly. We sometimes still get the session error page immediately after opening a new page while we have another page open for long time.
    Could anyone please help to look at our Filter and heatbeat funtion? Is there anything wrong with our Filter or the heartbeat? Why does the session still expire before we close the page?
    All we do here is to try to avoid the initial probelm with saving data after session and the application module expires. If anyone has a better solution to this problem, we would very much like to try. Appreciate if anyone can share some ideas!
    Thanks in advance!
    *1. ApplicationSessionExpiryFilter.java*
    public class ApplicationSessionExpiryFilter implements Filter {
    private FilterConfig _filterConfig = null;
    public void init(FilterConfig filterConfig) throws ServletException {
    _filterConfig = filterConfig;
    public void destroy() {
    _filterConfig = null;
    public void doFilter(ServletRequest request, ServletResponse response,
    FilterChain chain) throws IOException, ServletException {
    HttpServletRequest httpRequest = (HttpServletRequest)request;
    boolean sessionInvalid = false;
    if(httpRequest.getRequestedSessionId() != null) {
    if(!httpRequest.isRequestedSessionIdValid()) {
    if (!httpRequest.getRequestURI().endsWith("sessionExpired.do")) {
    sessionInvalid = true;
    if (sessionInvalid) {
    ((HttpServletResponse) response).sendRedirect(_filterConfig.getInitParameter("SessionTimeoutRedirect"));
    else {
    chain.doFilter(request, response);
    *2. Heartheat.html* (A small html page to be invoked by template.jsp periodically)
    <html>
    <head>
    <META Http-Equiv="Cache-Control" Content="no-cache, must-revalidate">
    <META Http-Equiv="Pragma" Content="no-cache">
    <META Http-Equiv="Expires" Content="Expires: Mon, 26 Jul 1997 05:00:00 GMT">
    </head>
    <body>
    heartbeat to keep session alive!
    </body>
    </html>
    *3. Template.jsp* (Template page to be extended by all jsp pages, invoke heart.html every 5 min)
    <Html>
    <body>
    <div id="heartbeat" style="display:none">
    </div>
    <script type="text/javascript" language="javascript">
    new Ajax.PeriodicalUpdater('heartbeat','jsp/template/heartbeat.html',{ method: 'post', frequency: 300, decay: 1 }); // update heartbeat.html every 300 sec(5min)
    </script>
    </body></html>

    Hi Shay,
    Reviewing ADFContex methods it seems that this object shouldn't be accessible from BC. Example:
    public static ADFContext initADFContext(java.lang.Object context,
                                            java.lang.Object session,
                                            java.lang.Object request,
                                            java.lang.Object response)
        Initializes the ADFContext for the environment of the specified context.
        Parameters:
            context - the ServletContext or PortletContext of the current execution environment.
            session - the HttpSession or PortletSession of the current execution environment. OPTIONAL.
            request - the HttpServletRequest or PortletRequest of the current execution environment. OPTIONAL.
            response - the HttpServletResponse or PortletResponse of the current execution environment. OPTIONAL.
        Returns:
            the ADFContext that was current when init was invoked. Should be passed back to resetADFContext after the block requiring the ADFContext has completed.Kuba

  • Urgent: Sessions problem pls help me

    Hi all,
    Its already late to post this problem.pls help me urgently.
    I have a servlet & two jsp's. first i request servlet, it processes something and forwards request to my first jsp. In that jsp on a button click, i'm displaying a new popup by calling showModalDialog. this dialog gets data from the same servlet but it forwards to my second jsp.(second jsp can be seen in dialog)
    Now if i submit form from my second(dialog) jsp, the servlet reports that session has expired. I tried a lot but invain. any one who helps me is appreciated well by all of our forum.
    waiting 4 u r reply,

    It could be that you have cookies turned off and you're not using URL Rewriting.
    In J2EE, the first time your browser makes a request to the server, the server responds and appends a SESSION_ID parameter to the request as well as storing a cookie with the SESSION_ID.
    The second time your browser makes a request, the server checks for the cookie. If it doesn't exist it checks for the parameter. If neither exist the server assumes its the first time your browser has made a request and behaves as describe in the previous paragraph.
    In your case when you submit the form if you have disabled cookies and the action attribute doesn't have the SESSION_ID paramter appended to the url, the browser will assume it's a first request. The user will not be logged in, hence your session has expired error.
    To fix this you need to encode the URL in your JSP. You can use the struts html:rewrite tag or the HttpServletReponse.encodeURL method, or if you're using JSP 2.0 the JSTL c:url tag.

  • Session problems in tomcat 5.0.28

    Even I shutdown the tomcat 5.0.28 server the session variable is still existing and it is showing the old values. What I have to do to disable the old values? Is it the problem with tomcat 5.0.28 or with JSP coding!

    Tomcat serializes sessions to the hard drive when it shutsdown. If you don't want this you have three choices:
    1: you can disable this functionality in the server.xml. Check the documentation.
    2: you could just delete the session.ser file when you shut down tomcat. This file is under work/standalone/{webapp name}
    3: you could close and re-open the browser so that the old jsessionid will not be sent and a new session will be created. The old session will eventually time out.
    The third option is probably the easiest.

  • JSP Session Problems

    Hi, i am facing a problem of the Object set into a session not being visible to the others pages. what did i done wrongly?
    here is the code:
    in login.jsp (currently hardcode cos i haven recieve that part):
    <%@page import="fantasy.team.*,java.util.Vector" session="true"%>
    <%
    Team t = new Team("Kacheek FC");
    session.setAttribute("team",t);
    if( session.getAttribute("team") ==null){
         out.write("how come null");
    }else{
         out.write("not null");
    %>
    Select
    //End of coding
    not null will be printed
    Following code belong to selectPlayer.jsp:
    if( session.getAttribute("team") == null){          
              out.write("i am null");               }else{
              out.write("i am not null");
    i am null is printed
    what is wrong with my coding?
    thanks.

    i do a
    if(session.isNew())
    out.write("New");
    and the result is new.
    meaning that my session is invalidate.
    that explain my value from "gone" rite?
    how to solve this?
    thanks.

  • Session Problems(ConcurrentModificationException)

    Hi,
    I am facing some problems with session here.
    I get a java.util.ConcurrentModificationException whenever i try to empty the shopping cart.
    Could somebody pls kindly advise?
    Thanks in advance
    below is the code:
    <% String item = request.getParameter("itemName");
    if(item != null && item.equals("emptyCart")) {
    java.util.Enumeration attributeNames = session.getAttributeNames();
    while(attributeNames.hasMoreElements()) {
    String attributeName = (String)attributeNames.nextElement();
    session.removeAttribute(attributeName);
    } else if(item != null) {
    String attributeName = item + "CD";
    session.setAttribute(attributeName, item);
    %>

    Similar qus answered int his forum ..
    refer
    http://forum.java.sun.com/thread.jsp?thread=244532&forum=45&message=897268

  • Session problems on wls6.1

    We have two domains with an identical application but one can pass out login
    credential through the session without any problems and the other just
    cannot retrieve the reference from the session. Both have the same session
    settings. Can any one point me a direction to look at? Thank you.
    Jack Shieh

    We found out what the problem was. Turned out the domain name we used on the
    client side didn't match the one on the host, and therefore the session is
    recreated for every request.
    "Jack Shieh" <[email protected]> wrote in message
    news:41e5acba$1@mail...
    We have two domains with an identical application but one can pass out
    login credential through the session without any problems and the other
    just cannot retrieve the reference from the session. Both have the same
    session settings. Can any one point me a direction to look at? Thank you.
    Jack Shieh

  • Session Problems

    Hi,
    I have a PHP site that uses frames. The frameset loads
    another site (both on
    the
    same server) in the lower frame window. Every time the page
    changes in the
    lower frame the session id changes, how can I stop this
    happening?
    Thanks for your help

    Thanks for the instructions, but now I'm wondering that this isn't even my problem. My problem is extremely strange. Let me explain...
    I'm building a website called Project Squared. As of right now, we're using SSL certificates (maybe this has something to do with the problem). Anyway, I try to login with my correct user information, and it works. But then, if I just close the Safari window without actually exiting Safari, if I open a new window and try to login again, I have to enter either incorrect information, or no information at all, to login. I can only login with correct information again if I exit Safari completely. Is this common, or do you know a fix? Thanks a lot.

  • JSP Session problem in HTML frames????

    Hi everybody;
    I have a problem with session I think. My index page is created with 4 diffrent jsp's in 4 diffrent frames.After a while lets say 15 minutes when my session is expired.When I click one of my button ..The frames which linked with that button is show Http 500 error page.When I refreshes the web page they all gone.(and my web page goes normal again)
    I want to ask you how can I handle this problem.How can I solve this error page showing and stop showing that error page instead of in each frame,to refresh the index page again??
    Thanks for your consideration.....

    The first step is to decide whether 15 minutes is a suitable timeout for sessions.
    If it isn't then simply increase it in web.xml. You may also decide that session persistence is worth enabling (if your Servlet container supports it).
    If it's not then your pages will need to handle a null (or at least new) session slightly more elegantly. You're probably just getting a null pointer exception because something your pages is relying on is missing (a session attribute of some sort). Sometimes it's sufficient just to redirect the topmost window to the index page - not the greatest user experience in the world but at least consistent.
    Hope this helps.

  • Session problem in one out of two jsp

    Dear java guru's
    I have got jsp page A.jsp.User select few option and this jsp calls
    B.servlet this takes user input and pass to
    C.bean which returns vector to B.servlet
    This servlet put vector in session and dispatch to new jsp
    D.jsp which calls
    E.jsp in it for Image generation.
    This E.jsp retrieve vector from session and generate a image and reurn to D.jsp
    Now my problem is that session in B.servlet and D.jsp are same but a new session in created in E.jsp so image is null as it could get data from vector which is null.
    I put System.out.println(session.getId()) in each servlet and jsp so to get thier ID's.
    This is working fine in my system with Tomcat 3.2 but on web the new session is created for E.jsp
    I am calling E.jsp like this
    <img src=<%=response.encodeURL("/iscap/report/jspChart.jsp")%> alt="generation image" width="400" height="350" border="1">
    I am making page session=true in each jsp and also puttting request.getSession(false);
    but still E.jsp is getting new session.I tried eliminating each one and made all combination that could be possible but not effect.
    How Can I solve this problem on the web where I have to load this?
    Do I have to make setting in context .
    payal sharma

    Hi,
    If you have been using jspChart v 1.00 :
    As shown in the modified , attached PPT :
    I will be displaying a bar chart. The length of bar chart is obatined from Sybase database. This chart should be dynamically created depending on the value on
    the database and x -axis is exponential.
    This will be displayed on a HTML page.
    1. I want to know whether,the values can be obtained the values from Sybase database ?
    If so, what are the changes.
    2. can you tell me the steps to install and run the jspchart v 1.00 on Jrun or any server please.
    Any thing else, I need to install like SAX , JCLARK. I am getting errors in this. PL HELP.
    3. Is it possible to plot "Exponential values" in the Y-axis. like 0 - 100- 1000 - 10000 - 100000
    and the length of the Bar should automaticall be coloured till that Point as shown in the Power point attached.
    If not, any suggestions to use any other software.
    Thanks in advance.
    [email protected]

Maybe you are looking for