dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: Remember what was clicked before login

  1. #1
    Join Date
    May 2010
    Posts
    35

    Remember what was clicked before login

    How can I remember what was clicked when:

    1) the user is browsing
    2) clicks a restricted (members only) page
    3) logs in
    4) I want them to go back to the restricted page if login is successful

    Thanks

  2. #2
    Join Date
    May 2010
    Posts
    123
    I have also been thinking about this, the only way that I can think of is:

    1. On every page save the url in $_SESSION['current_page'] (not on the login page though).
    2. Then when the user visits a restricted area they will login.
    3. If login successful then redirect to the $_SESSION['current_page']

    I have also come across $_SERVER['HTTP_REFERER'], not sure if this will work though:
    http://www.electrictoolbox.com/php-h...erer-variable/

  3. #3
    Join Date
    May 2010
    Posts
    35
    Thanks Dex. Does anyone know of a way of doing this without starting a session? I'd like to only start a session if the users are logged in, this will cut down on lurkers starting sessions (I don't know if this will affect performance or not).

    If I use $_SERVER['HTTP_REFERER'], and the loggin fails, say they slip a wrong keystroke, then it is lost without it being set as a session variable.

  4. #4
    Join Date
    Nov 2008
    Posts
    2,477
    You will need to use sessions or a cookie (sessions is better). Don't worry about the overhead, it is minimal to the point of insignificance. You only need to start the session when the user visits the restricted page, and you will presumably be starting one when they log in anyway.
    Last edited by Mindzai; 06-17-2010 at 11:15 AM.

  5. #5
    Join Date
    May 2010
    Posts
    35
    Quote Originally Posted by Mindzai View Post
    You will need to use sessions or a cookie (sessions is better). Don't worry about the overhead, it is minimal to the point of insignificance. You only need to start the session when the user visits the restricted page, and you will presumably be starting one when they log in anyway.
    Ok. Thanks to both of you.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles