#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    Hong Kong
    Posts
    24
    Rep Power
    0
    Hello

    I am using the new session management function from PHP4.
    session_start()

    how do u redirect a user to another page if his session is expired?

    here is what i want to do:

    1. user Tom enter his correct username and password.
    2. my system use session_register() function register a variable in his cookie.
    3. user Tom clicked Logout
    4. my system use session_destory() function and redirect Tom to the login page.
    5. Now, Tom click the 'BACK' button of his browser, a page showed 'page expired, hit reload button ... ...'.

    here is my question, how do I redirect Tom to the login page if he clicked the BACK button?


  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    27
    Rep Power
    0
    i guess you should use a cookie or somewhat
    trigger a variable that shows if the user is logged in or not

    ------------------
  4. #3
  5. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,645
    Rep Power
    4492
    I'm also running into problems with this. The problem is that the script isn't executed when the person clicks the back button, it just displays the same page that was cached. so checking a cookie or variable will not hav e any effect. i'm thinking there might be a way to do this in javascript (preventing the use of the back button entirely), and i posted something to the javascript forum. i'll let you know what i hear.

    if anyone else has any ideas, please let us know...
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    63
    Rep Power
    15
    To redirect the user...
    header ("Location: Login.php4");

    Re your javascript question, you can set the page to timeout();
  8. #5
  9. No Profile Picture
    Dave Bryant
    Guest
    Devshed Newbie (0 - 499 posts)
    You should be able to put head tags with nocache option set: Here are some header examples:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <meta name="ROBOTS" content="INDEX, NOFOLLOW">
    <meta http-equiv="refresh" content="3600">
    <meta http-equiv="Window-target" content="_top">
    [/code]

    I can't remember what the cache one is named but it is set with value "nocache".

    Then user will be foreced to reload. Or set the refresh to low value, either way hope it helps.

    ------------------
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    1
    Rep Power
    0
    http://www.php.net/manual/function.header.php

    That is where the function header. An important note is that it must come before the body of the page.
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    1
    Rep Power
    0
    This one is also nice: You can put some more useful stuff in your the header-part. This one is very useful to prevent caching:
    header ("Expires: Mon, 31 Dec 1990 06:00:00 GMT");
    header ("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
    header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header ("Pragma: no-cache"); // HTTP/1.0

    ------------------
  14. #8
  15. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    <form>
    <input type="button" value="Go" onClick="window.location.replace('nextpage.html');">
    </form>

    The current pages history entry will be replaced with the nextpage.html and this will also load the nextpage.html.

    (originally posted by Spookster)

    You can mess around with this to get the desired effect.

    Simon

    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL

Similar Threads

  1. Can user A read user B's session?
    By Stupid Khor in forum PHP Development
    Replies: 9
    Last Post: May 11th, 2004, 05:19 AM
  2. redirect to another page
    By ivan447 in forum PHP Development
    Replies: 2
    Last Post: February 12th, 2004, 10:44 AM
  3. Replies: 2
    Last Post: February 11th, 2004, 11:41 PM
  4. Assigning multiple session id
    By Stupid Khor in forum PHP Development
    Replies: 4
    Last Post: February 2nd, 2004, 07:12 AM
  5. How to redirect to another page?
    By sdotsen in forum PHP Development
    Replies: 6
    Last Post: January 31st, 2004, 10:14 PM

IMN logo majestic logo threadwatch logo seochat tools logo