Forum OpenACS Development: Referer url

Collapse
Posted by josue ruiz on
Hi to everyone,
I have a problem trying to get the refer page from the header, when the last page was a page which only has the tcl page and not the adp page, the url that I get when I request the referer page isn't the correct I get the previously what should be,

Im trying with this instruccion

[ns_set get [ad_conn headers] Referer]

I suppose that it could be because I dont have the adp page,

Someone know another way to get the previously page, no matter if it hasn't adp page

Thanks!

Collapse
2: Re: Referer url (response to 1)
Posted by Iuri Sampaio on
Josue,

You can always pass return_url between pages.
This way you can be sure you have the proper page assigned to your variable

It would be great if you post your code here, then i could understand what you are trying to achieve.

anyway, if the previous page is only a .tcl page then you probably is using something like ad_returnredirect or a form.
Either way you could:
a) ad_returnredurect [export_vars -base "next-page" {return_url}]

*don't forget to add return_url in the ad_page_contract.

b) input type='hidden' name='return_url' value='$return_url'

or if you are using ad_form
...
{return_url:text(text)
{value $return_url}
}
...

Those were just ideas. As i said i need more details to guide you better.

I hope it helps
Cheers,

Collapse
3: Re: Referer url (response to 2)
Posted by josue ruiz on
Thanks iuri sampaio,

But that isn't a solution for me, because with this i have to change a lot of the pages already created, so i just create a page that make validations between all those pages, thats the reason that i tried to use the Referer from the header but it doesn't work to me.

Collapse
4: Re: Referer url (response to 1)
Posted by Dave Bauer on
What exactly are you trying to accomplish by retrieving the referer?

Perhaps if you can show a sample of the tcl code from the referring page we can suggest a solution.

Collapse
5: Re: Referer url (response to 4)
Posted by josue ruiz on
ok
I'm doing this

if {![regexp "$return_url.*" "$referer"]} {
ad_returnredirect $return_url
}

if the referer is the same of the return_url I show the html that i want, but if aren't the same I redirect using the return_url

all works fine only when i access a page without an adp page, becasuse the referer isn't the correct(how I wrote in the first post), and doesn't make the if well.

Collapse
6: Re: Referer url (response to 1)
Posted by Dave Bauer on
Ok

Either

1) It looks like using ad_returnredirect does not set the referrer header as you wish.

or

2) You are calling ad_returnredirect without an ad_script_abort call after it.

If #1 is the case you'll need to do something different.

What is the reason you need to verify the referrer is the same as the passed in return_url?

Collapse
7: Re: Referer url (response to 6)
Posted by josue ruiz on
Thanks to everyone,

I already solve my problem using the < meta HTTP-EQUIV="REFRESH" content="0; url=page3" >, but in openacs there is a function that do it.

I relplace the

ad_returnredirect

by
util_ReturnMetaRefresh

so in this way i already can read the correct referer page
;)