Then in my login form I have this bit. (commented out for now) #url.pagerequested# as of now I am using the originalurl input field. but it chops off the query string after the first variable. and session.originalurl always throws element originalurl undefined in session error. I have double checked the spelling(actually copy/pasted to make sure they are the same) I just would like to know how/why url.originalurl is getting hacked down, even though its correct in the address bar. Or why I can't seem to get session.orginalurl to be set. Thanks for the help everyone. [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => JoeyTMann [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 8 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> Then, in your login page
[allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => BKBK [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 9 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> redirect to originally requested page after login - Coldfusion - Advanced Techniques

redirect to originally requested page after login - Coldfusion - Advanced Techniques

I am trying to think but nothing happens. I have a website that is protected by a login app that uses cfldap against an active directory domain to login users. One thing I would like to do is that if a user requests a page say http://server/dir/page.cfm?var=34 that gets saved somehow(session var?) so when users get directed to http://server/login/login.cfm when they complete the login process it takes them back to http://server/dir/page.cfm?var=34. I have tried using #cgi.http_referer# but that seems to get lost when the user is pushed to the login form. Once the login form complete cflocation is used to ...

  1. #1

    Default redirect to originally requested page after login

    I am trying to think but nothing happens. I have a website that is protected by
    a login app that uses cfldap against an active directory domain to login users.
    One thing I would like to do is that if a user requests a page say
    http://server/dir/page.cfm?var=34 that gets saved somehow(session var?) so when
    users get directed to http://server/login/login.cfm when they complete the
    login process it takes them back to http://server/dir/page.cfm?var=34. I have
    tried using #cgi.http_referer# but that seems to get lost when the user is
    pushed to the login form. Once the login form complete cflocation is used to
    push them to the main page of the site. Any help/suggestions would be greatly
    appreciated.

    JoeyTMann Guest

  2. #2

    Default Re: redirect to originally requested page after login

    You can either set a variable that is passed (URL) or stored (Session/Cookie)
    with the original value.

    Or you could have ANY page become the login page. Use a CFINCLUDE to include
    the login page (which would need to resubmit to itself. That way they never
    really leave the page they had requested. You might need to do this in an
    Application.cfm file or include the logic on every secure page. I use Fusebox,
    so this can be handled easily with that.

    Umbrae Guest

  3. #3

    Default Re: redirect to originally requested page after login

    I just discovered a small problem, if the query_string is too long(contains
    multiples variables...page.cfm?id=1&name=joey&age=2)part of it gets chopped off
    and replaced with &CFID=494705&CFTOKEN=23819926. Not a big deal at the moment
    as the only pages I send out via email contain one variable, but there are
    others that I would like to start doing this with and it is kinda of annoying
    to have this error.

    JoeyTMann Guest

  4. #4

    Default Re: redirect to originally requested page after login

    Yeah, a URL is a long thing to stuff into a URL variable. I would make is a Session/Client variable or a Cookie.
    Umbrae Guest

  5. #5

    Default Re: redirect to originally requested page after login

    I tried using <cfset session.orginalurl="#cgi.SCRIPT_NAME#?#cgi.QUERY_S TRING#">
    but I always get "Element ORGINALURL is undefined in SESSION. " when using it.

    Do I need to init the var with something else?

    I have inheireted this site so I never wrote the login portion of it. I barely
    am a capable CF programmer as it is, so my understanding of why the previous
    person did things the way he did evades me most of the time. Oh and I had his
    job rolled into mine...fun stuff.

    JoeyTMann Guest

  6. #6

    Default Re: redirect to originally requested page after login

    OK I know how the cfid and cftoken bits got in there. my cflocation tag that
    redirects to the requested page didn't have addtoken="no". But only one of the
    url vars is being passed. I confirmed that the #url.requestedpage# is correct
    in the url, but when I use it in <input size="100" type="hidden"
    value="#url.pagerequested#" name="originalurl"> value gets chopped down to
    /page/file.cfm?action=detail when it should have &order=1658 on the end.

    JoeyTMann Guest

  7. #7

    Default Re: redirect to originally requested page after login

    tried using <cfset session.orginalurl="#cgi.SCRIPT_NAME#?#cgi.QUERY_S TRING#">
    but I always get "Element ORGINALURL is undefined in SESSION. " when using
    it.

    Defined in your Application.cfm a login boolean variable,
    e.g.<cfparam name="session.userLoggedIn" type="boolean" default="false">.
    This variable will of course be updated to True once the login is succeessful.

    Then, wherever you call session.originalurl, make sure you do so as follows
    <cfif NOT session.userLoggedIn>
    <cfset session.orginalurl="#cgi.SCRIPT_NAME#?#cgi.QUERY_S TRING#">
    </cfif>




    BKBK Guest

  8. #8

    Default Re: redirect to originally requested page after login

    ok here is a code snippet from my application.cfm in the root of my site.


    <cfif NOT IsDefined("Session.LoggedIn")> <!--- USER has not tried to login
    --->
    <cflocation
    url="/Login/loginPnet.cfm?pagerequested=#cgi.SCRIPT_NAME#?#cgi .QUERY_STRING#"
    addtoken="No">

    <cfset session.originalurl="#cgi.SCRIPT_NAME#?#cgi.QUERY_ STRING#">

    </cfif>
    <cfif Session.LoggedIn does not contain "yes"> <!--- USER failed logged in
    --->
    <cflocation
    url="/Login/loginPnet.cfm?pagerequested=#cgi.SCRIPT_NAME#?#cgi .QUERY_STRING#"
    addtoken="No">

    </cfif>


    Then in my login form I have this bit.

    <cfoutput>
    <!---<input type="hidden" value="#session.originalurl#"
    name="blah">--->(commented out for now)
    </cfoutput>
    <cfif isdefined('url.pagerequested')>
    <cfoutput>

    <input size="100" type="hidden" value="#url.pagerequested#" name="originalurl">
    #url.pagerequested#
    </cfoutput>
    </cfif>

    as of now I am using the originalurl input field. but it chops off the query
    string after the first variable.
    and session.originalurl always throws element originalurl undefined in session
    error.
    I have double checked the spelling(actually copy/pasted to make sure they are
    the same)

    I just would like to know how/why url.originalurl is getting hacked down, even
    though its correct in the address bar. Or why I can't seem to get
    session.orginalurl to be set.

    Thanks for the help everyone.

    JoeyTMann Guest

  9. #9

    Default Re: redirect to originally requested page after login

    <cfparam name="session.userLoggedIn" type="boolean" default="false">

    cfif IsDefined("Session.LoggedIn") AND Session.LoggedIn is FALSE>
    <!--- USER not logged in--->
    <cflocation
    url="/Login/loginPnet.cfm?pagerequested=#cgi.SCRIPT_NAME#?#cgi .QUERY_STRING#"
    addtoken="No">
    </cfif>


    Then, in your login page
    <cfif isDefined("url.pagerequested")>
    <cfset requestedPage="#url.pagerequested#">
    <cfelseif isDefined("form.username")>
    <cfset requestedPage="#form.originalurl#"
    <!--- login validation goes here --->
    </cfif>

    <form action="#cgi.script_name#"...>
    <input type="text" name="username"...>
    <input type="password" name="pw"...>
    <input size="100" type="hidden" value="#requestedPage#" name="originalurl">
    <input type="submit"...>
    </form>


    BKBK Guest

  10. #10

    Default Re: redirect to originally requested page after login

    BKBK, first off thanks for the help.

    But. the same thing is happening. #pagerequested# doesn't have the entire
    string. The full value of url.pagerequested is
    /dir/index.cfm?go=here&ticket_id=1013, but #pagerequested# is
    /dir/index.cfm?go=here. Things work great if there is only one var in the query
    string, but anything more gets left off. Could there be a setting in CFIDE
    Admin that I may need? Sorry if I seem to be flopping around like a fish out of
    water....just getting a little frustrated with myself.

    JoeyTMann Guest

  11. #11

    Default Re: redirect to originally requested page after login

    ok, after banging around on it, i tried to see if maybe the ticket_id var was
    in the url scope and sure enough it was there. So I tried to use
    #cgi.query_string# in the login page, and out popped pagerequested=var=1&var=2.
    Sweet, did #rereplace(cgi.query_string,"pagerequested=","")# and there was my
    full intact url that I needed.

    Thanks everyone for the help and suggestions.

    JoeyTMann Guest

Similar Threads

  1. Login redirect back to previous page
    By Glen T in forum Coldfusion Database Access
    Replies: 2
    Last Post: September 18th, 11:33 PM
  2. Forms Authentication won't redirect to login page
    By Max Figueredo via .NET 247 in forum ASP.NET Security
    Replies: 1
    Last Post: September 26th, 07:50 PM
  3. Replies: 6
    Last Post: September 10th, 04:22 AM
  4. Login User and Redirect to a specific page - help required
    By Alex Billerey in forum Macromedia Dreamweaver
    Replies: 1
    Last Post: July 22nd, 12:18 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •