Results 1 to 13 of 13
  1. #1
    Join Date
    Jan 2004
    Location
    Sydney
    Posts
    11

    Question Unanswered: losing cookies and changing session.id, ... why?

    I have developed a web application using IIS 5.1 and asp pages and IE 6.0.

    From the login page(login.asp), it goes to another asp page(adddata.asp) on which there is a form with several buttons that use javascript to open new asp pages(T1.asp, T2.asp, T3.asp, etc.), depending on which button was clicked. If a button is clicked it opens the new browser window and keeps the adddata.asp page open. T1.asp and T2.asp, etc. is have forms and one submitted writes the data into cookies. Once the adddata.asp page is submitted it goes to recorded.asp and writes all the collected data from cookies and session variables into the database.

    Problem is that it loses some of the cookies if more than 2 new windows are opened. If forms on adddata.asp, T1.asp and T2.asp are filled in and submitted it works fine, but I cannot go any further than this because it drops cookies, and not always the same ones either. It also changes the session.id even though there has been no change in domain or even directory.

    What am I doing wrong?

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Are you able to post some of your pages so we can have a look at exactly what you are trying to do??

  3. #3
    Join Date
    Jan 2004
    Location
    Sydney
    Posts
    11

    Thumbs up

    Attached is the main form that contains the several buttons.

    Thanks.
    Attached Files Attached Files

  4. #4
    Join Date
    Jan 2004
    Location
    Sydney
    Posts
    11
    and here is one of the asp pages that loses the cookies...
    Attached Files Attached Files

  5. #5
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    so when you say it is losing cookies... which of these values does it lose?

    UserKPI
    ClientName
    Reason_T3_
    Date_T3_
    ConNote_T3_
    T3Attempt_

    Or does it lose them all??

  6. #6
    Join Date
    Jan 2004
    Location
    Sydney
    Posts
    11
    It usually loses only a few cookies and not always the same ones. Mostly it loses a few of these:

    Reason_T3_x
    Date_T3_x
    ConNote_T3_x
    T3Attempt_ x

    With x being 1,2,3 etc. it will write 1 and 2 and then drop 3, or 3 and drop 1 and 2... weird stuff. That's why I don't think it's the code.

    :-)

  7. #7
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    No disrespect intended but, I think it might be the code... if it was the browser I think it would be less erratic. I'll find some time this afternoon to have a good go over the code. I suspect it has something to do with this

    Code:
    Dim varT3_2
    varT3_2 = request.cookies("T3cookie") 	
    x=1
    For x=1 to varT3_2
    	Response.Cookies("UserKPI")=request.cookies("UserKPI")
    	Response.Cookies("ClientName")=request.cookies("ClientName")
    	Response.Cookies("Reason_T3_" & x)=request("Reason_T3_" & x)
    	Response.Cookies("Date_T3_" & x)=request("Date_T3_" & x)
    	Response.Cookies("ConNote_T3_" & x)=request("ConNote_T3_" & x)
    	Response.Cookies("T3Attempt_" & x)=request("T3Attempt_" & x)
    next
    But I'm not sure why.... are you setting the T3cookie correctly because I can't find any other reference to it.
    Last edited by rokslide; 02-10-04 at 18:25.

  8. #8
    Join Date
    Jan 2004
    Location
    Sydney
    Posts
    11
    I would really appreciate your time. It may very well be my code. The T3cookie is set at the top of the T3.asp page. Is that where I am going wrong?

    Dim varT3
    varT3 = request("T3")
    response.cookies("T3cookie") = varT3

  9. #9
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Hmmm,.. okie, well I have had a look and I can't see anything wrong with it to be honest,... do you have this up somewhere where I can play with the whole thing just to see the behaviour you have meantioned?

    Just a thought,... if you are losing your session id, or rather it is changing, it almost infers that your conneciton is being dropped,... what sort of server software are you using?
    Last edited by rokslide; 02-10-04 at 22:24.

  10. #10
    Join Date
    Jan 2004
    Location
    Sydney
    Posts
    11
    Sorry - it is only on our intranet. No web access is possible because if the location of the database. The web server has Windows XP, IIS 5 and the web pages connect to another server that has Oracle 8 installed. How can I test to see if the connection is being dropped?

    Thanks for the help... can you think of anything else I can try?

  11. #11
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Apart from running a pile of debugging on the scripts I can't really think of anything.... You might be right, it might be the server causing the problems... I can't really be sure though...

    Doing the debugging should prove it though.

  12. #12
    Join Date
    Jan 2004
    Location
    Sydney
    Posts
    11
    What I have had to do is redesign my pages so that the buttons did not open a new page but rather slotted in a few extra lines on the form on the same page. It works, and does not lose any cookies.

    Code:
    <td colspan="2" align="right">Total number of containers not put away </td>
    <td colspan="2">
    <input name="W3" type="text" id="W3" size="5" value="<% = valueW3 %>">
    <INPUT name="button3" type="submit" id="button3" onclick="return OnButton3();" value="more.."> 
    Click on more to capture details </td>
    <% If request.cookies("button3")="more.." then %>
    <% If request("W3")>0 then %>               
    <div id="W3">
    <%
    Dim varW3
    varW3 = request("W3")
    x=1
    For x=1 to varW3
    
    Set OraDynaset = OraDatabase.DbCreateDynaset( _
        "select * from W_Reasons where question='W3' order by Reason", cint(0))
    fAttempt=Request("W3Attempt_" & x)
    %>
    	 <tr bgcolor="#F5F9FD"> <td><B>
    	 <% = x %>.</B>  Error made by<br>
    	 <% Select Case fAttempt
    	  Case "us"  %>
    	<input name="W3Attempt_<% response.write x%>" type="radio" value="us" checked>us
    	<input name="W3Attempt_<% response.write x%>" type="radio" value="Cus">
    			Client
    			<% Case "Cus"  %>
    			<input name="W3Attempt_<% response.write x%>" type="radio" value="us">us
    			<input name="W3Attempt_<% response.write x%>" type="radio" value="Cus" checked>
    			Client
    			<% Case Else  %>		  
    			<input name="W3Attempt_<% response.write x%>" type="radio" value="us" unchecked>us
    			<input name="W3Attempt_<% response.write x%>" type="radio" value="Cus" unchecked>
    			Client
    			<% end select %>
                      
    </td>
    <td>Reason :<br>                
    <select name="Reason_W3_<% response.write x %>">
    <option ><% If Request("Reason_W3_" & x)<>"" Then Response.write Request("Reason_W3_" & x) Else Response.write "Select Reason" end if %></option><% Do While(OraDynaset.EOF = FALSE) %><option value="<% = OraDynaset.Fields("Reason") %>"><% = OraDynaset.Fields("Reason") %></option>
    <% OraDynaset.MoveNext 
    Loop
    %></select></td>
                  <td>Container. no.<br>
                    <input name="Container_W3_<% response.write x%>" type="text" size="10" maxlength="20"> </td>
                  <td>Date (dd/mm/yyyy): 
                    <input name="Date_W3_<% response.write x%>" type="text" size="10"></td>
    </tr>
    <%
    Next
    %> 
    </div>
    <% end if %>
    <% end if %>
    Thanks Rokslide for the help.

  13. #13
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Cool, all looks sweet. Since this is an intranet app you could probably get away without using cookies at all and instead use a hidden form field to how all the details (probably storing it as XML or something).

    Also if you are moving it to a single page and thus not loosing your sessionid perhaps you could store everything in session variables...

    Yet another thought would be to have a single page with div's for each section. You would have to use some DHTML to dynamicly create the required number of fields but it should work okie.

    Anyhow, hope I was of some help. Sorry I couldn't solve the orginal problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •