Jump to content

Traffic Cop for Redirecting Pages??


doubledee

Recommended Posts

How do you handle redirecting pages?

 

I am working on a module where people can add comments to an article, but the redirecting logic isn't as easy as it seems.  (And if I think about the redirecting logic for my entire website it gets even trickier?!)

 

With this current module...

 

To add a comment, you must be a logged in Member, so that either means you have to "Create an Account" or "Log In".

 

Here are two scenarios:

 

Scenario #1: Visitor

A Visitor is on "article1234.php" and wants to add a comment.  The path they take goes...

 

"article1234.php" to "create_account.php" (display) to "create_account.php" (post) to email to "activate.php" to "log_in.php" (display) to "log_in.php" (post) to "article1234.php"

 

 

Scenario #2: Member Not Logged In

A Member - who is not logged in - is on "article1234.php" and wants to add a comment.  The path they take goes...

 

"article1234.php" to "log_in.php" (display) to "log_in.php" (post) to "article1234.php"

 

 

I was able to get away using  $_SESSION['referringPage'] = $_SERVER['HTTP_REFERER']; in Scenario #2, but that won't easily work for Scenario #1.

 

The problem is that sometimes a redirect is just to where you were just at, and other times it is several steps back to where you were in the past.

 

It is almost as if you need a "Redirect Lookup Table"?!

 

Follow me?

 

 

Debbie

 

 

Link to comment
Share on other sites

You could set a $_SESSION['cache_post'] variable using a hidden field in your "post comment" form, hold that through to the end of sign up/in and then call it with an if exists contitional at the point of final log in.

 

I'm curious though, how does your system differentiate between a looged out member and a new user?

Link to comment
Share on other sites

I've never seen a site that accomodates scenario #1.

 

Scenario #2 can be done with a simple session variable storing the article ID. On login, check for the variable and clear it, then redirect to the article. If you must cater for scenario #1 then the same can be used but you need to make sure you don't end up redirecting people that didn't want to be redirected.

 

It depends on how your comment system works i.e does it shown the comment form to guests, then when posting takes them to login, or does it hide the form for guests and they have to click login/create account.

Link to comment
Share on other sites

You could set a $_SESSION['cache_post'] variable using a hidden field in your "post comment" form, hold that through to the end of sign up/in and then call it with an if exists contitional at the point of final log in.

 

I'm curious though, how does your system differentiate between a looged out member and a new user?

 

Any article would check

if $_SESSION['loggedIn'] == TRUE{

 

 

Debbie

 

 

Link to comment
Share on other sites

I've never seen a site that accomodates scenario #1.

 

Oh, I think it's pretty common.

 

 

It depends on how your comment system works i.e does it shown the comment form to guests, then when posting takes them to login, or does it hide the form for guests and they have to click login/create account.

 

There is an article.  Below it is a Comments area.  In the Comments header is, "What do you think?" followed by either an "Add a Comment" button if the user is a Member and logged in, OR a message, "To add a comment, you must either 'Log In' (button) or 'Create an Account' (button)" for users that are not logged in or visitors.

 

If you aren't logged in, you can't add a comment because there is no button even though the comment field is below.

 

Make sense?

 

 

 

Debbie

 

Link to comment
Share on other sites

You didn't read his post correctly.

 

@Funster - The new user would visit the signup page, rather than the login page.

 

The only issue with using sessions is it won't always be consistent. If the user has two tabs open, one tab might change session variables that the other relies on. Besides that, it's a great way to track it. Personally, I'd just pass it in the query string

 

article1234.php -> login.php?ref= article1234 -> login.php?ref=article1234 -> if ($_GET['ref']) { redirect }

Link to comment
Share on other sites

@Funster - The new user would visit the signup page, rather than the login page.

I'm confused.  What was that statement in regard to?

I asked how the site it's self could be aware and differentiate between members who were not logged in and strangers who did not have an account.  I'm not asking how it handles each group.

 

...I'd just pass it in the query string

I assume you are actualy talking about the URL?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.