Creating Databases for Web Applications - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Creating Databases for Web Applications

Description:

... a computer (your own or in a lab) for cookies and shared objects. ... Cookies, web beacons, Flash SharedObjects are used frequently for marketing purposes. ... – PowerPoint PPT presentation

Number of Views:52
Avg rating:3.0/5.0
Slides: 17
Provided by: Jeanin
Category:

less

Transcript and Presenter's Notes

Title: Creating Databases for Web Applications


1
Creating Databases for Web Applications
  • Persistent information. Cookies. Session
  • Homework Examine a computer (your own or in a
    lab) for cookies and shared objects. Experiment
    with cookie programs. Read article.

2
Persistent data (aka state information)
  • Data that lasts longer than one loading of an
    html page
  • Store information on the server
  • File
  • Database
  • Store information on the client computer
  • Cookie
  • Flash terminology SharedObject
  • Keep information for the session by sending and
    re-sending it with the HTTP headers
  • Php session construct

3
Cookies
  • Meant to be disarming name
  • Small file stored on client computer accessible
    by programs on the same domain (some limitations
    possible here), with some time limits
  • YOUR computer
  • PROMISE that these files don't do harm. There
    have been 'leaks' on IE
  • Cookies can be set by program running on client
    (e.g., JavaScript) or server (e.g., php)

4
Marketing
  • Cookies, web beacons, Flash SharedObjects are
    used frequently for marketing purposes.
  • HomeworkCathy Dwyer articlehttp//csis.pace.edu
    /dwyer/research/AMCISDwyer2009.pdf

5
Show cookies
  • FireFox Tools Options Privacy Show Cookies
  • IE Tools Internet Options General Settings
    (under Browsing history) View files
  • ???

6
Flash player
  • Settings manager for new sites
  • http//www.macromedia.com/support/documentation/en
    /flashplayer/help/settings_manager03.html
  • Settings for sites already visited (trust that
    list is complete?)
  • http//www.macromedia.com/support/documentation/en
    /flashplayer/help/settings_manager07.html117717

7
Browser (user) limits
  • Your user/customer/player/client may choose to
    forbid all cookies or
  • Make decision case by case.
  • Note most people don't do this, but designers
    should make plans
  • Retain information some other way
  • php session, store information on server, ?
  • Make user re-enter information
  • Cookies are browser specific. If you visit a site
    using IE and set cookies and then Firefox, it
    won't pick up the cookie

8
Setting and using cookies
  • Required
  • Name
  • Value
  • Optional
  • expires. Time from a base time. JavaScript uses
    milliseconds. PHP uses seconds! Default is the
    end of the browser session
  • path. Default is path of calling document
  • Would allow other scripts in the document
    directory. If you want to restrict it further,
    put in more information "/Jeanine/db/"
  • domain. Default is domain of this document
  • By setting domain to purchase.edu, I can allow
    scripts from newmedia.purchase.edu AND
    www.purchase.edu, etc.
  • secure. True requires secure transmission

9
Javascript
  • document.cookie mycookie
  • Where mycookie is a string like a query string,
    consisting of cookienamecookievaluepath
  • domain
  • secure.
  • NOTE cookiename and cookievalue are your name
    and value.

10
JavaScript example
  • http//newmedia.purchase.edu/Jeanine/cookie.html
  • Examine source code
  • The setcookie and getcookie functions are much
    more general than needed.
  • Code uses the conditional operator and also the
    construct (expires). Does this value exist (is it
    set)?
  • Expiration is a year from now
  • 365 24 60 60 1000

milliseconds
11
PHP cookies
  • setcookie(name, value, expires,path,domain,secure)
    where the last 4 are optional
  • NOTE actually, the last 5 are optional. To
    delete a cookie with the name blahsetcookie(blah)
  • CAUTION setcookie must occur before any HTML
    produced (print, echo).
  • Watch out for blank lines!

12
cookies.php
  • No expiration time set. Expires when browser is
    closed.
  • One file form and handler of form
  • Outline
  • If form submitted
  • Set cookie
  • Welcome message
  • Else get cookies already set (if they exist)
  • display form

13
  • lt?php
  • submitted_POST'submitted'
  • if (_at_(submitted))
  • cname_POST'cname'
  • type_POST'type'
  • setcookie("ccname",cname)
  • setcookie("ctype",type)
  • ?gt
  • lthtmlgtltheadgtlttitlegtUse cookie lt/titlegtlt/headgt
  • ltbodygt
  • lth1gt Welcome
  • lt?
  • print ("cname! lt/h1gt\n")
  • print ("ltbrgtYou like type cookies.")
  • ?gt
  • ltbodygt lt/htmlgt
  • lt?

14
  • else
  • ccname_COOKIE'ccname'
  • ctype_COOKIE'ctype'
  • ?gt
  • lthtmlgtltheadgtlttitlegtForm for cookies
    lt/titlegtlt/headgt ltbodygt
  • ltform action"cookies.php" methodpostgt
  • Your name ltinput typetext name'cname'
  • value'lt?print (_at_ccname) ?gt'gt ltbrgt
  • Your favorite cookie ltinput typetext
    name'type'
  • value'lt? print (_at_ctype) ?gt'gt ltbrgt
  • ltinput typehidden name'submitted' valueTRUEgt
  • ltinput typesubmit value'send info'gtltinput
    typereset value'reset'gt
  • lt/formgt lt/bodygt lt/htmlgt
  • lt? ?gt

15
cookies5min.php
  • Note the cookies.php cookies may expire quicker
    or longer than this one.
  • If you use both, what happens???
  • Expiration is given in SECONDS!!!!
  • This code also prints out the time in
    milliseconds, just for fun.
  • setcookie("ccname",cname,time()560)
  • setcookie("ctype",type, time()560)

16
Homework
  • Write (set) and read cookies!
  • Read Cathy Dwyer article
  • Use tools to examine cookies on your own computer
  • Prepare to discuss
  • Keep working on enhancements to basic projects
Write a Comment
User Comments (0)
About PowerShow.com