/    Sign up×
Community /Pin to ProfileBookmark

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

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@DexterMorganJun 17.2010 — 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-http-referer-variable/
    Copy linkTweet thisAlerts:
    @quark76authorJun 17.2010 — 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.
    Copy linkTweet thisAlerts:
    @MindzaiJun 17.2010 — 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.
    Copy linkTweet thisAlerts:
    @quark76authorJun 17.2010 — 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.[/QUOTE]

    Ok. Thanks to both of you.
    ×

    Success!

    Help @quark76 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.19,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...