Week 7 IBS 685. Displaying an Image using CFOUTPUT 1.Save images in a folder under wwwroot directory 2.Create a database column and name it e.g. imagefilename.

Slides:



Advertisements
Similar presentations
MFA for Business Banking – Security Code Multifactor Authentication: Quick Tip Sheets Note to Financial Institutions: We are providing these QT sheets.
Advertisements

Using the Self Service BMC Helpdesk
Cookies, Sessions. Server Side Includes You can insert the content of one file into another file before the server executes it, with the require() function.
1 Configuring Internet- related services (April 22, 2015) © Abdou Illia, Spring 2015.
6/10/2015Cookies1 What are Cookies? 6/10/2015Cookies2 How did they do that?
XP Browser and Basics1. XP Browser and Basics2 Learn about Web browser software and Web pages The Web is a collection of files that reside.
DT228/3 Web Development multi page applications/ sharing data.
Week 2 IBS 685. Static Page Architecture The user requests the page by typing a URL in a browser The Browser requests the page from the Web Server The.
XP Tutorial 9 New Perspectives on JavaScript, Comprehensive1 Working with Cookies Managing Data in a Web Site Using JavaScript Cookies.
Client State Management & Application Security  Client State Management  Concept  ASP Examples  Application Security  Database Based Approach 
Session Management A290/A590, Fall /25/2014.
1 The World Wide Web. 2  Web Fundamentals  Pages are defined by the Hypertext Markup Language (HTML) and contain text, graphics, audio, video and software.
Browser and Basics Tutorial 1. Learn about Web browser software and Web pages The Web is a collection of files that reside on computers, called.
IBS 685 Week 6. Update Forms Updating Data The update process is as follows: –The user is presented with a list of rows and selects one row to update.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Cookies & Sessions.
Cookies Set a cookie – setcookie() Extract data from a cookie - $_COOKIE Augment user authentication script with a cookie.
CHAPTER 12 COOKIES AND SESSIONS. INTRO HTTP is a stateless technology Each page rendered by a browser is unrelated to other pages – even if they are from.
About Dynamic Sites (Front End / Back End Implementations) by Janssen & Associates Affordable Website Solutions for Individuals and Small Businesses.
Software Architecture for ColdFusion Developers Unit 4: Application Events and Global Variables.
XP New Perspectives on Browser and Basics Tutorial 1 1 Browser and Basics Tutorial 1.
JavaScript, Fourth Edition
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
Working with Cookies Managing Data in a Web Site Using JavaScript Cookies* *Check and comply with the current legislation regarding handling cookies.
CSE 154 LECTURE 12: COOKIES. Including files: include include("filename"); PHP include("header.html"); include("shared-code.php"); PHP inserts the entire.
Python CGI programming
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Chapter 8 Cookies And Security JavaScript, Third Edition.
School of Computing and Information Systems CS 371 Web Application Programming PHP – Forms, Cookies, Sessions and Database.
Week seven CIT 354 Internet II. 2 Objectives Database_Driven User Authentication Using Cookies Session Basics Summary Homework and Project 2.
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
1 Maryland ColdFusion User Group Session Management December 2001 Michael Schuler
Top Five Web Application Vulnerabilities Vebjørn Moen Selmersenteret/NoWires.org Norsk Kryptoseminar Trondheim
1 Chapter 9 – Cookies, Sessions, FTP, and More spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
11 1 Cookies CGI/Perl Programming By Diane Zak Objectives In this chapter, you will: Learn the difference between temporary and persistent cookies.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
STATE MANAGEMENT.  Web Applications are based on stateless HTTP protocol which does not retain any information about user requests  The concept of state.
Application.cfm tips and Tricks Michael Smith President TeraTech, Inc ColdFusion, database & VB custom development and training.
Sessions in PHP – Page 1 of 13CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: Sessions in PHP Reading: Williams.
Web Database Programming Week 7 Session Management & Authentication.
Cookies and Sessions IDIA 618 Fall 2014 Bridget M. Blodgett.
MEMBERSHIP AND IDENTITY Active server pages (ASP.NET) 1 Chapter-4.
Controlling Web Site Access Using Logins CS 320. Basic Approach HTML form a php page that collects the username and password  Sends them to second PHP.
How to Create an Address How to Create a Free Account, Read and Answer your s. Yahoo! provides FREE . To create a free .
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
PHP and Sessions. Session – a general definition The GENERAL definition of a session in the “COMPUTER WORLD” is: The interactions (requests and responses)
ITM © Port,Kazman 1 ITM 352 Cookies. ITM © Port,Kazman 2 Problem… r How do you identify a particular user when they visit your site (or any.
1 PHP HTTP After this lecture, you should be able to know: How to create and process web forms with HTML and PHP. How to create and process web forms with.
8-Mar-16 More About Servlets Session Tracking. Persistent information A server site typically needs to maintain two kinds of persistent (remembered) information:
Unit-6 Handling Sessions and Cookies. Concept of Session Session values are store in server side not in user’s machine. A session is available as long.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
COOKIES AND SESSIONS.
1 Chapter 22 World Wide Web (HTTP) Chapter 22 World Wide Web (HTTP) Mi-Jung Choi Dept. of Computer Science and Engineering
Distributed Web Systems Cookies and Session Tracking Lecturer Department University.
Joomla Awdhesh Kumar Singsys Pte Ltd. What is Joomla? Joomla is an award-winning content management system (CMS), which enables you to build Web sites.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
WWW and HTTP King Fahd University of Petroleum & Minerals
CONTENT MANAGEMENT SYSTEM CSIR-NISCAIR, New Delhi
ITM 352 Cookies.
What is Cookie? Cookie is small information stored in text file on user’s hard drive by web server. This information is later used by web browser to retrieve.
Configuring Internet-related services
Nate Nelson I*LEVEL, Inc.
CSc 337 Lecture 27: Cookies.
CSc 337 Lecture 25: Cookies.
Presentation transcript:

Week 7 IBS 685

Displaying an Image using CFOUTPUT 1.Save images in a folder under wwwroot directory 2.Create a database column and name it e.g. imagefilename Make sure that imagefilename column’s datatype is “Text” 3.Create a query that selects the imagefilename column 4.Create a img src tag where you want to display the image 5. Create a CFOUTPUT tag to display the image 6. The alt tag can be dynamic too. You can output the definition of the image if you have the information in your database.

The structures of the (such as the recipient list, the subject line and sender) is specified in attributes to the CFMAIL tag. The content of the message is placed between opening and closing CFMAIL tags. The critical attributes used in the CFMAIL tag are: To: specifies the address of the recipients From: Specifies the content of the From line of the message Subject: Specifies the Subject line of the

CFMAIL Example <CFMAIL Subject=“A sample Coldfusion ” This is my test message Type:Specifies the content type of the message Server: Specifies an alternate SMTP mail server. By default, the mail server specified in the CF administrator is used for sending outgoing messages

CFMAIL <CFMAIL TO="recipient“ FROM="sender" SUBJECT="msg_subject" TYPE="msg_type" MIMEATTACH="path“> Before you can use the tag to send messages, you need to specify a mail server in the CF Administrator.

Generating from the Contents of a Form Send a Greeting Send a Greeting Use the following form to send a greeting to a friend by Your Friend's Address: Your Name:

Sending Your Greeting <CFMAIL TO="#Form.to#" SUBJECT="A Greeting">Hi! This is a quick, computer-generated greeting sent to You courtesy of #Form.name# and the CFMAIL tag. Message Sent Your message to #Form.to# has been sent Oops You need to provide an address for the recipient. Hit the Back button to return to the form and provide one. Thanks. Generating from the Contents of a Form

Structures Structures are the most powerful data type in Coldfusion. Structures provide a way to store data within data.

Structures #contact.firstname# #contact.lastname# ---> #StructCount(contact)#

p.175 Is an invaluable diagnostics and debugging tool capable of displaying all sorts data in a clean and easy to read format.

Introducing Web Application Framework

WAF Features all have to do with making all your CF pages for a particular site behave as if they were related to one another –that is to make them behave a single application.

WAF The Web application framework is designed to help you with the following: –Consistent look and feel –Sharing variables between pages So far the variables that you have worked all “die” when each page request has been processed. Variety of ways to maintain the values of variables between page requests.

WAF The framework is the force that binds your templates together.

Using Application.cfm To get started with the WAF, you first must create a special file called Application.cfm. This file is just an ordinary CF template. Only two things make Application.cfm special: –The code in your Application.cfm file will be automatically included just before any of your pages –You cant visit an Application.cfm directly. You will receive an error message from CF.

Application.cfm File(page 382) CF looks for an Application.cfm file in the directory of the called page. –If not found in the current directory, CF will continue to search the directory structure for a file named Application.cfm –If found, the Application.cfm file will be included at the top of the page –If not found, CF continues processing the page without it.

Listing 16.1 Application1.cfm <!--- Filename: Application.cfm (The "Application Template") Created by: Nate Weiss (NMW) Please Note: All code here gets executed with every page request!! Purpose: Sets "constant" variables and includes consistent header ---> You can refer to this variable as the datasource attribute for all the tags in the application, as in datasource=“#datasource#”

Using Application.cfm #CompanyName#

OnRequestEnd.cfm (page 385) Automatically included at the very end of every page request, rather than at the beginning. This file cannot be visited directly CF looks for OnrequestEnd.cfm in the same folder as application.cfm Place OnrequestEnd.cfm in the same location in which your Application.cfm is sitting.

OnRequestEnd.cfm

Another Example (c) #year(Now())# #CompanyName#. All rights reserved.

Working with Sessions( Page 417) WAF focusing on the features that let you track variables on a per-user basis. This opens up all kinds of opportunities for keeping track of what each –user needs, –wants, –has seen –or interacting with.

The Web's Statelessness Page 417 HTTP creates a new connection for every page request –Variables and flags set during one request are not available for the next request Work around this problem by using: –Cookies –Application framework –Session variables

Solutions Provided by ColdFusion CF provides three types of variables that help you maintain the state of a users visit from page to page and between visits. –Cookies –Client Variables –Session Variables

HTTP Cookie Variables Cookies are simple variables that can be stored on a client machine. Browsers store cookies in a physical file or files on the client machine. Once the browser has a cookie set, each and every HTTP request will retrieve all cookies for the requested web server domain.

If the user requests a page from the Macromedia domain, all cookies for that domain would be sent in the HTTP header to the web server. Once the browser send the cookies via the HTTP header, CF has access to all of these cookies at runtime. HTTP Cookie Variables

Cookies are: –Domain specific-set and retrieved for specific servers. –Sent to the Web server with every HTTP request –Persistent-they remain stored in the browser until expired or deleted –Limited to 20 per domain and 4 K worth of information.

Cookie Uses Cookies are used to obtain information about a user between and within browser sessions. Use of cookies include: –Storing a unique identifier as a cookie, so that information such as shopping cart data is identified to the browser session. –Storing a session information, such as a flag that they are logged in until the browser is closed. –Storing user preferences, so they might return to the site and have the same look and feel.

Making Cookies CF allows you to create cookie by using tag. The most common reason for using is to control how long the cookie will live before before it expires. To set a cookie with user_ID with value of 2344: –

Cookie Types There are two types of cookies you can create: Persistent cookies Session cookies Both can be created using the tag Differentiated by the use of the EXPIRES attribute.

Persistent vs. Session Cookies Persistent Cookies: –EXPIRES attribute determines when the cookie gets deleted from the browser machine: EXPIRES = "n" EXPIRES = "date" EXPIRES = "never" EXPIRES = "now"

Session Cookies Created by omitting the EXPIRES attribute from the tag Only valid until all the browser sessions on that client machine are closed Use this value when you only want to track the user for the current session Destroyed when the browser sessions close, and are never stored in a file on the browser machine

Accessing Cookies Since HTTP specifies that all cookies be automatically sent to the requesting Web server domain, you do not need to fetch them. You would access a cookie simply by using it and prefixing it with the Cookie prefix. –The user_ID is: – #cookie.user_ID#

Because cookies are physical files stored on the browser computer that can be deleted at will, you should always test for the existence of cookies prior to use. –Test for existence using the IsDefined () function The user ID is: #cookie.user_ID# Accessing Cookies

Session Variables Session variables are: –Stored in the Web server's memory –Lost when the Web server is restarted –Used for single site visit Session variables are not stored physically in the server’s or in the database. Instead they are stored in the servers RAM In order to use Session variables, you will need to: 1.Check the ColdFusion Administrator for Session settings 2.Enable Session variables within your Application.cfm file 3.Set Session variables in your ColdFusion pages

ColdFusion Administrator Settings Session variables must be enabled before use. Check the following settings in the ColdFusion Administrator to: 1.Make sure that Session variables have not been disabled 2.Set/reset the Session variables default and maximum timeout settings

ColdFusion Administrator Settings11-22 Found in the ColdFusion Administrator in the Server Settings section under Memory Variables

Enabling Session Variables Enable session variables by using tag. This tag is always included in Application.cfm file. Enable session variables in the Application.cfm file: Enables session variables and sets expiration to 1 hour after last browser activity for each session The maximum timeout default in the ColdFusion Administrator is 20 minutes. Change this value in order for the above tag to allow timeout at 1 hour.

After you have enabled session variables using, you can start using them in your code. You can set and use session variables by simply using the Session prefix in front of a variable’s name.

1.The first time a browser requests a page from ColdFusion, it will encounter the tag. This is always placed in an Application.cfm file. 2.ColdFusion will generate a unique identifier for the browser. The unique ID is made up of two values: CFID and CFTOKEN. 3.Two cookies are created and sent to the browser: CFID and CFTOKEN. 4.These two values are also stored in the Web server’s memory within the application. This is the link between the Web server and the browser session.

Creating Session Variables Session variables are stored in server memory with the matching CFID and CFTOKEN values Each session will have a separate set of variables Once the association between the browser and the session is made, session variables can be created using the tag The Session. prefix is required

Creating Session Variables Session variables are stored in server memory with the matching CFID and CFTOKEN values Each session will have a separate set of variables Once the association between the browser and the session is made, session variables can be created using the tag The Session. prefix is required

Securing your Applications This line must be wrapped within whatever code validates a users password This line must be put on whatever pages you need to protect Sorry, you don’t have a permission to look at that

<!--- Filename: Application.cfm Created by: Nate Weiss (NMW) Please Note: Executes for every page request ---> <CFAPPLICATION NAME="OrangeWhipSite" SESSIONMANAGEMENT="Yes"> All pages in your application have now been locked down and will never appear until you create code that sets the session.auth.isloggedin value

Loginform.cfm <!--- Filename: LoginForm.cfm Created by: Nate Weiss (NMW) Purpose: Presented whenever a user has not logged in yet Please Note: Included by Application.cfm ---> Please Log In Read last paragraph of page 473 (cgi script) Please Log In Username: <CFINPUT TYPE="Text" NAME="UserLogin" SIZE="20" VALUE="" MAXLENGTH="100" REQUIRED="Yes" MESSAGE="Please type your Username first."> Password: <CFINPUT TYPE="Password" NAME="UserPassword" SIZE="12" VALUE="" MAXLENGTH="100" REQUIRED="Yes" MESSAGE="Please type your Password first.">

Logincheck.cfm <!--- Filename: LoginCheck.cfm Created by: Nate Weiss (NMW) Purpose: Validates a user's password entries Please Note: Included by LoginForm.cfm ---> SELECT ContactID, FirstName FROM Contacts WHERE UserLogin = '#Form.UserLogin#' AND UserPassword = '#Form.UserPassword#'