How to redirect users back to a specific page using Sessions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rahia307
    New Member
    • Jun 2007
    • 32

    How to redirect users back to a specific page using Sessions

    hi
    i use session for login and logout. but i have problem. i want to redirect the page where i come from login. but i cannot do this.
    in other words what is the procedure after login i redirect the page where i come from login.
    plz help me for this
  • musa007
    New Member
    • Jun 2007
    • 1

    #2
    Hi Rahia.

    Try the following:

    [code=php]
    if (strpos($_SERVE R['HTTP_REFERER'], 'xyz.php'))
    {
    header('Locatio n:'.$_SERVER['HTTP_REFERER']);
    }
    [/code]
    Here, we are searching the PHP variable ($_SERVER['HTTP_REFERER']) for an occurance of the string (xyx.php).

    If this is true, then the page is directed to itself (i.e. reloaded) on this occassion ($_SERVER['HTTP_REFERER']).

    If you want to redirect to another page, simply change:
    header($_SERVER['HTTP_REFERER'])
    -to-
    header('Locatio n:' XXX);
    where XXX is the appropiate URL.

    I hope this helps.
    Last edited by Atli; Jun 18 '07, 10:15 AM. Reason: Added Code tags

    Comment

    Working...