简体   繁体   中英

how to redirect url to previous url using perl

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 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. eg you might use the header method from CGI.pm.

Make sure that that URL you redirect to is a real URL (eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM