session timeout problem (missing link)

3 views
Skip to first unread message

Don Smith

unread,
Nov 25, 2010, 1:00:43 AM11/25/10
to TrafficMunkey Support Forum
Hi there,

I seem to have a session timeout issue that causes a missing link
error to be thrown. I have a site that requires the user to be logged
in to access the pages within it. That works great, until the session
times out. When I click a link that only a logged in user should have
access to I get this missing link error instead of being redirected
back out to the site that doesn't required login.

Here is my site map:
<site title="Main" template="templates/default.cfm"
disableCaching="true" urlVariable="page">

<!--- this listens for the janrain token being submitted during a
login --->
<object name="Request.Authentication" component="lib.login">
<listener name="authorize" object="Form" property="token"
config="#config#"/>
</object>

<site title="Auction" roles="false">
<page id="Home" title="Welcome to <cfoutput>#config.site_name#"
template="templates/home.cfm">
<link id="Home" name="Home" url="" hint="Go to Default Page" />
<link id="Logout" name="Logout" url="" hint="Logout" />
<link id="Account" name="Account" url="" hint="Account" />
</page>
</site>

<site title="Login">
<page id="Login" title="Login" template="templates/login.cfm">
<link id="Home" name="Success" url="" hint="Go to Default Page" />
<link id="Home" name="Home" url="" hint="Go to Default Page" />
</page>
<page id="Logout" title="Logout" template="templates/logout.cfm">
<link id="Home" name="Success" url="" hint="Go to Default Page" />
</page>
</site>

<site title="Account" template="templates/account.cfm" roles="true">
<page id="Handle" title="Handle" template="templates/handle.cfm">
<link id="Handle" name="Handle" url="" hint="Go to Default Page" />
<link id="Logout" name="Logout" url="" hint="Logout" />
<link id="Home" name="Home" url="" hint="Go to Default Page" />
<link id="Account" name="Account" url="" hint="Account" />
</page>
<page id="Account" title="Account" template="templates/
account_view.cfm">
<link id="Logout" name="Logout" url="" hint="Logout" /><link
id="Handle" name="Handle" url="" hint="Go to Default Page" />
<link id="Logout" name="Logout" url="" hint="Logout" />
<link id="Home" name="Home" url="" hint="Go to Default Page" />
<link id="Account" name="Account" url="" hint="Account" />
</page>

</site>

</site>

The url I'm trying to hit when my session has timed out is index.cfm?
page=Handle. The link it complains about missing is the Home link,
which is referenced in the templates/default.cfm.

Missing Link!
This page attempted to use a link named 'Home' which does not exist.
Make sure that a url or page id for this link is specified.

I think I've created Home link references everywhere, but it still
complains. Any ideas?

Thanks,

Don

MillionMunkeys

unread,
Nov 25, 2010, 10:31:56 AM11/25/10
to TrafficMunkey Support Forum
Hi Don,

I'll take a look. It might be a bug. It looks like you're using the
URL variables approach, vs. direct page access. What version of CF
are you running? Behavior between versions 6, 7, and 8+ can be a
little different, because of ColdFusion's evolving CFC models.

Pete

Don Smith

unread,
Nov 25, 2010, 3:08:53 PM11/25/10
to traffi...@googlegroups.com
I am using CF9. I am not committed to URL variables, that's just the approach I got working. I was having troubles with the direct page access and getting the site templates to work with them.

=Don

--
For group membership options, visit this group at
http://groups.google.com/group/trafficmunkey?hl=en

MillionMunkeys

unread,
Nov 26, 2010, 4:31:38 PM11/26/10
to TrafficMunkey Support Forum
Don, as we had talked about, the quick answer is to add the
handleMissingInclude="false" attribute to the base site tag. I'm
posting here for reference. I probably will make "false" the default
in the next patch version. Displaying the missing include error is
really a debugging feature, not production. So your main site tag
will look like this:

<site title="My App" template="template.cfm" disableCaching="true"
handleMissingInclude="false">
...
</site>

The result is that instead of displaying the error, it will redirect
to the default page in the site, which should be what you are looking
for.


pete

On Nov 25, 3:08 pm, Don Smith <donwsm...@gmail.com> wrote:
> I am using CF9. I am not committed to URL variables, that's just the
> approach I got working. I was having troubles with the direct page access
> and getting the site templates to work with them.
>
> =Don
>

Don Smith

unread,
Dec 29, 2010, 4:35:46 PM12/29/10
to traffi...@googlegroups.com
Hi Pete,

I'm still having this Missing link error when the session times out and i try to refresh the page that requires the user to be logged in. And I do have the handleMIssingInclude param set to false in the main site tag. Any other ideas?

Thanks,

Don

MillionMunkeys

unread,
Jan 2, 2011, 5:36:48 PM1/2/11
to TrafficMunkey Support Forum
I'm going to start working on the next planned update to
TrafficMunkey, which will have much better handling of user
permissions. The plan is that instead of throwing a Missing Include
error when the page exists but is hidden because of user permissions,
instead TrafficMunkey will traverse up the site tree, until it finds a
parent site for which the user does have permissions, and then serve
up the default page for that site for the user's roles (or lack of
roles in the case of a session logout).

In the meantime, the work-around is to put a cftry/cfcatch block
around the site definition tags and catch an error of type
"TrafficMunkey.MissingLink". In there you'll do a cflocation to
Request.TrafficMunkey.get('baseURLPath') & "index.cfm".

<cftry>
<site title="MySite" template="template.cfm" disableCaching="true"
handleMissingInclude="false">
<page title="Login" template="login.cfm" roles="false">
<cfparam name="Session.lastURL" default="" />
<link name="success" url="#Session.lastURL#" />
</page>
<site title="User Management" roles="true">
...
</site>
<page title="Logout" template="logout.cfm" roles="true">
<link name="success" url="" />
</page>
</site>
<cfcatch type="TrafficMunkey.MissingLink">
<!--- Always throw error during debugging.
<cfrethrow> --->
<cfif Arguments.targetPage neq
Request.TrafficMunkey.get('baseURLPath')&"index.cfm">
<!--- If their login has expired, save the request page, so we
can return after authentication. --->
<cfif ListLast(CGI.SCRIPT_NAME,"/") neq "login.cfm">
<cfset Session.lastURL = CGI.SCRIPT_NAME & "?" &
CGI.QUERY_STRING />
</cfif>
<!--- If their login has expired, return to the base URL. --->
<cflocation url="index.cfm" addtoken="no">
<cfelse>
<cfrethrow>
</cfif>
</cfcatch>
</cftry>

While debugging, though, you'll want to always do a <cfrethrow>
instead, in case there are any true MissingLink errors, like
forgetting a <link> tag with a <page> tag, or linking to a page that
doesn't exist in your site map yet.

<cfcatch type="TrafficMunkey.MissingLink">
<!--- Always throw error during debugging. --->
<cfrethrow>
<cfif Arguments.targetPage neq
Request.TrafficMunkey.get('baseURLPath')&"index.cfm">
<!--- If their login has expired, save the request page, so we
can return after authentication. --->
<cfif ListLast(CGI.SCRIPT_NAME,"/") neq "login.cfm">
<cfset Session.lastURL = CGI.SCRIPT_NAME & "?" &
CGI.QUERY_STRING />
</cfif>
<!--- If their login has expired, return to the base URL. --->
<cflocation url="index.cfm" addtoken="no">
<cfelse>
<cfrethrow>
</cfif>
</cfcatch>


Pete

Don Smith

unread,
Jan 4, 2011, 12:33:08 AM1/4/11
to traffi...@googlegroups.com
Yeah, so I had all that code, including the <cfrethrow>, which is what was tripping me up. It was working as designed. :)

Once I removed the <cfrethrow> everything worked fine.

Thanks!

Reply all
Reply to author
Forward
0 new messages