COMP249 Web Technology
Tutorial - Week 7
Answer the following questions and hand in your answers in a text file (Notepad .txt) via WebCT before 9am, Monday 7th April.
- Write down the HTTP cookie headers exchanged in the following
series of requests:
- Client requests /cgi-bin/browse.py from server
- Server returns a cookie 'id' with a value 'xy128' set to expire in 100 seconds
- Client requests /cgi-bin/browse.py?category=toys
- Server returns page
- Client requests /cgi-bin/select.py?item=s12830
- Server returns a cookie 'item' with a value 's12830:1' to expire in 1 day, resends 'id' cookie with same value to expire in 1 day
- Client requests /cgi-bin/checkout.py
- Write the segments to set or read cookies in Python for the above question.
Additional topics for discussion in the tutorial (not for handing in):
- You are designing a website that will allow users to log in
and customise the site's look and feel by choosing background
colours and fonts etc. Users can also choose which news
headline sources should be displayed on the front page. There
are two ways to support this behaviour:
- Issue users with a cookie once they have logged in. The value of this cookie will identify the user in your database so that you can retrieve their preferences.
- Issue users with a cookie whose value encodes their preferences, eg. "bgcolor=red:font=arial:headlines=abc,smh"
-
A news website stores stories in a relational database. It uses the stories table with fields date, author, topic title and text. Write SQL queries to:
- find the title and text of all stories.
- find the title of all stories written by author 'Eric'.
- find the title of all stories written by author 'John' on topic 'technology'.
- insert a new story in the database
- Give two reasons why relational databases are a good idea for storing data in large websites.