开发者

how to redirect url to previous url using perl

开发者 https://www.devze.com 2023-02-03 02:30 出处:网络
In my website, a user can view all pages without sign in but some information not displayed. Also when a user sign in, user can view all details of every page. my problem is, user views home, profile,

In my website, a user can view all pages without sign in but some information not displayed. Also when a user sign in, user can view all details of every page. my problem is, user views home, profile, portfolio, account 开发者_Go百科page..... some page then go to sign in. after sign in, my webiste(url) redirect to previous page (before sign in page). how can i do using perl


Include the URL to redirect to in a hidden input in the login form.

If you have the login form on each page, then just include it directly. If you have a link to the login form, then pass the previous page in the query string.

If the login is successful, then redirect by issuing a Location HTTP header. How you do that depends on the HTTP library you are using. e.g. you might use the header method from CGI.pm.

Make sure that that URL you redirect to is a real URL (e.g. by parsing it with URI) and that it is on your own domain to avoid XSS attacks and attempts to use your site to redirect people to spam.

0

精彩评论

暂无评论...
验证码 换一张
取 消