7

Click here to load reader

Sessions and Flash

Embed Size (px)

Citation preview

Page 1: Sessions and Flash

SESSIONS AND FLASHWhat goes in a hash?

Page 2: Sessions and Flash

REVIEW: WHAT IS A SESSION?

A session is a hash that will store information on the client’s server until the session times out or is deleted.

Ex: creating a new session at login to remember a user until they log out or exit the application.

Page 3: Sessions and Flash

FUN FACTS

➤ Sessions are “lazily loaded”, meaning they will only load if you use them. If you choose not to use sessions, you don’t have to disable them.

➤ You can use the reset_session method to reset the entire session hash.

➤ To store data that persists from session to session, you can store a session in the CookieStore.

Page 4: Sessions and Flash

WHAT IS THE FLASH HASH?

Much like a session, a flash is a bit of information that is stored on the client’s server. A flash will only last from one request to the next.

Page 5: Sessions and Flash

MORE ABOUT FLASH

➤ You can create different types of messages, such as :notice or :alert.

➤ You can also create custom alerts such as:

➤ To display multiple flash messages, iterate through the hash using each.

Page 6: Sessions and Flash

OTHER WAYS TO USE FLASH

flash.now

flash.keep

Page 7: Sessions and Flash

FUN FACT

➤ Bootstrap has alert classes that can be used to display flash messages.