开发者

redirecting to custom url if session expires or if a page requires login

all of our users have custom urls. user.domain.com. when a session expires, the page gets routed to index.php. I need it to require it to redirect to user.domain.com so that they can login from that page. The problem is how can i capture that information t开发者_运维百科o redirect to the custom url. Also, let say that sombody tries to go to user.domain.com/home.php but it requires login. How can i redirect for it login at user.domain.home.php

Thanks!


You should simply include a php script in every page, above the code. such as:

include('auth.php');

That should check if the login is correct using the session variables. If it's not correct, destroy the currect session login information (to be sure) and redirect the user to the login form...

header("Location: login.php");

That's a fast response.


Your question does not sound very clear to me. Anyway, concerning the second part of your question, you can simply do something like this:

<?
session_start();
if($_SESSION["logged"]!=1 or !isset($_SESSION["logged"])) 
header("Location: loginPage.php");
?>

does this answer your question?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜