[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 476
  • Last Modified:

IFrame & Sessions

I've a question, I've included the calendar_v1.asp ASP caledar.  

The code is in a include file in an iframe.

I was wondering when the user changes the month/year, and then goes to a different page, is there a way to keep the month/year settings?  At the moment it goes back to the current month/year.  

I just want this while they are currently on the site, no need for cookies.

Here's the code:

http://12.10.191.180/code/calendar_code.txt

Thanks,
Suzanne
0
ssaville24
Asked:
ssaville24
  • 3
  • 2
  • 2
  • +1
2 Solutions
 
mattfairwCommented:
if i'm understanding your question...that may be a bit difficult. you could pass queary strings to all your pages which would be cumbersome...or could have hidden form fields which could be cumbersome...or you could use session variables, but that wouldn't work if the user had cookies disabled on their machine.  If your user needs to log in first, you could add a column to your database containing their last date chosen and a second column containing their current session id(which you grab using ASP but i forget the command right now). then when the user goes to the calendar page, check and see if a session exists for their account...if so, see if it matches their current session id...if those both are valid, then you can read in the previously chosen date value and use that.  the session id is used to make sure you're only loading the previously chosen date if the user is still on their original session. if they close of of the browser, and go back to the page, then it wouldn't load the date and they could choose a new one again, this could be omitted if that's not the case. Also, when the user does select a date...amke sure to update their DB values


This seems like a bit much, and i may be missing something obvious...its been a long day ;).   Cheers
0
 
cjinsocal581Commented:
session("datepicked") = Rs("Start_Date")

Then,
strDATE = session("datepicked")
response.write strDATE 'on other pages.

This goes with what mattfairw stated about session data. It is something I would use in this case. Set your session timeout to a length based on how long you think your users will be on that particular site.
0
 
ssaville24Author Commented:
There is no login required for this site.  How would I go about this with just sessions variables?  This is an internal website, and users will not have cookies disabled.  Thanks for your comments so far, but we have not worked in a login yet for users.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
cjinsocal581Commented:
You didn't mention you needed a "login" portion for your site. You just asked about holding the calendar data throughout your site.

Based on your comments, you can use cookies, sessions or stored database information to perform the functions you need.

So, here is some code I use for login type sites:
______________________________________________
login.asp
______________________________________________
<html>
<head>
<title>Login</title>      
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
 function putFocus(formInst, elementInst) {
  if (document.forms.length > 0) {
   document.forms[formInst].elements[elementInst].focus();
  }
 }
//  End -->
</script>
</head>
<%
Response.IsClientConnected
%>
<body onLoad="putFocus(0,0);">            

<table border="1" width="100%" id="table1" bordercolorlight="#000000" cellspacing="0" cellpadding="2" bordercolordark="#000000">
      <tr>
            <form method="POST" action="loginvalidate.asp" name="form1">
                  <td>
                  <p align="center"><b><font face="Verdana" size="2" color="#666666">
                  INFO LOGIN</font></b></p>
                  <div align="center">
                  <table border="0" width="32%" id="table2">
                        <tr>
                              <td width="88">
                              <font size="2" face="Verdana" color="#990000" style="font-weight: 700">Login :</font></td>
                              <td width="148"><font face="Verdana">
                              <input type="text" name="txtLogin" size="20" tabindex="1" id="field0"></font></td>
                        </tr>
                        <tr>
                              <td width="88"><b><font size="2" face="Verdana" color="#990000">Password :</font></b></td>
                              <td width="148">
                              <font face="Verdana">
                              <input type="password" name="txtPassword" size="20" tabindex="2"></font></td>
                        </tr>
                        <tr>
                              <td width="88">
                              <p align="center">
    <font face="Verdana">
    <input type="submit" value="Login" name="B1" tabindex="3"></font></td>
                              <td width="148">
    <font face="Verdana">
    <input type="reset" value="Clear Fields" name="B2" tabindex="4"></font></td>
                        </tr>
                        </table>
                        </div>
                  </td>
            </form>
      </tr>
      </table>
</body>
</html>
_____________________________________________________________________________
loginvalidate.asp
_____________________________________________________________________________
<%
' -------------------------------------------------------------------------
      ' Retrieve the registration form fields and store them to local variables
      ' -------------------------------------------------------------------------
      strLogin = Request.Form("txtLogin")
      strPassword = Request.Form("txtPassword")

      ' -------------------------------------------------------------------------
      ' Open the connection
      ' -------------------------------------------------------------------------
      Set objConn = Server.CreateObject("ADODB.Connection")
      Set RS = Server.CreateObject("ADODB.Recordset")
      
      '--------------------------------------------------------------------------
      ' Define the Connection String for the database object as the database string
      '--------------------------------------------------------------------------                  
      objConn.ConnectionString = "Provider=sqloledb;Data Source=SQLsvr;Initial Catalog=sqlDB;User Id=sqlUser;Password=sqlpassword;"
      objConn.CursorLocation = 3
      objConn.Open
                                                      
      '--------------------------------------------------------------------------
      ' Set the SQL Query
      '--------------------------------------------------------------------------
      strSQL = "SELECT * FROM UserTable WHERE (UserName = '" & strLogin & "')"
      
      '--------------------------------------------------------------------------
      ' Execute the query.
      '--------------------------------------------------------------------------
      RS.open strSQL, objConn
      
      '--------------------------------------------------------------------------
      ' If there is no matching login name, or the password does not match,
      ' print an error to the visitor and stop the processing of this page.
      '--------------------------------------------------------------------------
      If RS.EOF <> FALSE Then
      Response.Redirect("login_error.asp")
      ElseIf Trim(RS("Passwd")) <> Trim(strPassword) Then
      Response.Redirect("login_error.asp")
      Response.End
      End If

         Session("strLogin") = strLogin
      'Session("userName") = RS("Engineer")
      Session("x") = RS("QTYLogged")
      
      '--------------------------------------------------------------------------
      ' The user is validated, time to update the last login time. First close the
      ' old connection, now build the SQL query to insert the new record.
      '--------------------------------------------------------------------------
      RS.Close
      Dim x
      Dim y
      Dim z
      x = Session("x")
      y = 1
      z = x + Y
      State = "ON"
      strSQL = "UPDATE UserTable SET UserTable.QTYLogged = '" & z & "', UserTable.LoggedONorOFF = '" & State & "' WHERE (UserName = '" & strLogin & "')"
      
      '--------------------------------------------------------------------------
      ' Execute the query.
      '--------------------------------------------------------------------------
      RS.open strSQL, objConn
      
      '--------------------------------------------------------------------------
      ' Now redirect the user to the main page as a logged in user.
      '--------------------------------------------------------------------------
      
      Session("strLogin")
      Response.Redirect("validated.htm")
%>
_____________________________________________________________________________
login_error.asp
_____________________________________________________________________________
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Login Error</title>
<SCRIPT LANGUAGE="JavaScript">
function Back() { window.location = "login.asp"; }
</script>
</head>
<body>
<table border="1" width="100%" id="table1" cellspacing="0" bordercolor="#000000">
      <tr>
            <td>
            <p align="center">Login Error</p>
            <p align="center">Incorrect user name or incorrect password.</p>
            <p align="center">
    <font face="Verdana">
    <input type="button" value="Back To Login Page" name="B2" onclick="Back()" tabindex="4"></font></td>
      </tr>
</table>
</body>
</html>
___________________________________________________________________________________________________

Good luck!
0
 
ssaville24Author Commented:
No sorry, I meant there is no login required for this site (at least not at this point). I was just replying to mattfairw...

If your user needs to log in first, you could add a column to your database containing their last date chosen and a second column containing their current session id(which you grab using ASP but i forget the command right now). then when the user goes to the calendar page, check and see if a session exists for their account...

In saying that I just want to use session variables to remember what month the user selected when changing pages. Instead of storing in a database.

Do you understand?
0
 
cjinsocal581Commented:
Yeah.

All you need to do is something like this:

session("dateselected") = request.form("yourdate")
session("timeselected") = request.form("yourtime")

then you can do whatever you want with the session data.

strCalendardate = session("dateselected") & " " & session("timeselected")

Of course you will need to post the data somehow and I would use hidden fields.

<input type="hidden" name="dateselected" value="<%=(Rs("Start_Date"))%>">
0
 
mattfairwCommented:
sorry, i've been away for the day. But yes, it would seem in your case, session variables are the way to go. The code cjinsocal posted should be more than enough to get you started. let us know if there is anything else we can help with!

-Matt
0
 
WMIFCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.  I will make a recommendation to the moderators on its resolution in a week or two.  I appreciate any comments that would help me to make a recommendation.

Unless it is clear to me that the question has been answered I will recommend delete without refund of points.  It is possible that a Grade less than A will be given if no expert makes a case for an A grade.  It is assumed that any participant not responding to this request is no longer interested in its final disposition.

If the asker does not know how to close the question, the options are here:
http://www.experts-exchange.com/help.jsp#hs5

WMIF
EE Cleanup Volunteer
0
 
WMIFCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.  I will leave the following recommendation for this question in the Cleanup topic area:
Split - cjinsocal581, mattfairw

Any objections should be posted here in the next 4 days.  After that time, the question will be closed.

WMIF
EE Cleanup Volunteer
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now