To add some security, we need to check if a user has logged in; we can do this by using a tag that can be added at the top of each file that we want to secure. Let's add a custom tag called <cf_secure>
to our templates:
1. Create a template under the
videoshare
directory namedsecure.cfm
and add the following code:<cfif session.userid NEQ 0> <cfinclude template="login.cfm"> <cfabort> </cfif>
2. The tag is rather simple; it checks whether we have a
session.userid
set and makes sure it isn't equal to zero with theNEQ
operator. If it is not set, it includes ourlogin.cfm
template and then aborts the rest of the rendering of the page. If there is asession.userid
set, it will ignore this statement.3. At the top of the
upload.cfm
file, let's call the<cf_secure>
tag:<cf_secure> <cf_layout section="Upload Video"> <cfparam name="FORM.title" default=""> <cfoutput> <h1 id="upload_video">Upload...