Wednesday, March 18, 2015

Chapter 11 - Cookies and Sessions

Chapter 11 is all about cookies. Unfortunately, not of the edible kind. I just spent 5 minutes pointlessly looking for the phrase ">>>> TEST COOKIE WORKED!" on the registration page, when in fact, it's supposed to print in your console window. Oops. Don't make the same mistake I did. Read the directions closely.

Note to self: stuff is not printed to the rendered HTML. It is printed in the console. It's like a private message to yourself, allowing you to test new features!

Also, if you want to implement a grammatically correct site counter ("you have visited this site __ time(s)") without the (s), put this in your about.html file:

    {% if visits > 1 %}    
        <p>You have visited this site {{ visits }} times.</p>
    {% else %}
        <p>You have visited this site {{ visits }} time.</p>
    {% endif %}

An if/else statement to the rescue! Yay, grammar!

No comments:

Post a Comment