Jump to content

Recommended Posts

Hey guys. I don't really know the terminology to describe what I want to do, so I apologize if the subject is too vague.

 

When you try to go to a page that you need to be logged in to see, it first takes you to a login page. Once you successfully log in, it takes you to that original page that you tried to access instead of the default home page.

 

I've been doing PHP for a little while (oh about... 6 or 8 months) so I don't think I need any code, just some structure/pointers because I can't really think it through.

 

Thanks.

There are different ways to handle it, but here is a basic methodology.

 

1.User attempts to access a restricted page (Page A)

2. Page A checks to see if user is logged in (usually with an include file)

3. If user is not logged in, the current URL for Page A is saved to an "original page" session variable and the user is redirected to a login page

4. After the user successfully logs in the login page checkes if the "original page" session variable is set. If so the user is redirected to that page - if not the user is redirected to a default page.

So just store it in a session var? And if that var is set, put that var in the action of the login form, and if not, use some default page?

 

If you understand what you just said, then try it your way.

 

 

Here are three files that will assist you!

 

 

[attachment deleted by admin]

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.