Author Topic: Login Redirect - Is it possible to stay on the same page?  (Read 18192 times)

Offline fsuk

  • Posts: 127
Login Redirect - Is it possible to stay on the same page?
« on: July 08, 2008, 01:59:49 PM »
When a user logs in to my site they are redirected to the home page. Is it possible to modiffy class.login.php so that it stays on the same page as the one they logged in on?
You say deviant like its a bad thing...

Offline ruebenwurzel

  • Betatester
  • **
  • Posts: 8337
  • Gender: Male
  • Keep on Rockin
    • Familie Gallas Online
Re: Login Redirect - Is it possible to stay on the same page?
« Reply #1 on: July 08, 2008, 02:34:04 PM »
Hello,

don't modify the class.login.php, please only modify the login call in your template. Can easily be done by adding the redirect to the login action.

Matthias

Offline fsuk

  • Posts: 127
Re: Login Redirect - Is it possible to stay on the same page?
« Reply #2 on: July 08, 2008, 02:40:29 PM »
What is this redirect to login action. How do i implement it?

Current code in template for login menu:
Code:
Only registered users can see contents. Please click here to Register or Login.
You say deviant like its a bad thing...

Offline ruebenwurzel

  • Betatester
  • **
  • Posts: 8337
  • Gender: Male
  • Keep on Rockin
    • Familie Gallas Online
Re: Login Redirect - Is it possible to stay on the same page?
« Reply #3 on: July 08, 2008, 03:43:17 PM »
Hello,

a quick search in the forum for "redirect" gives you all the answers you need. You also will find this:

http://www.websitebaker2.org/forum/index.php/topic,9801.msg57796.html#msg57796

And please for the future, before asking a question, search the forum. Thanks

Matthias

Offline fsuk

  • Posts: 127
Re: Login Redirect - Is it possible to stay on the same page?
« Reply #4 on: July 08, 2008, 03:49:33 PM »
I think you miss-understand.

I dont want the user to be redirected to a login page.

When the user is on, for example, the events page and there is a login box underneath the menu they can login there. But once they click the login button and are logged in they are redirected to the home page, they do not remain on the same page.

What i want is for the user to click login on whatever page they may be on and for them to be logged in and remain on the same page.

Thanks for you help
You say deviant like its a bad thing...

Offline Ruud

  • WebsiteBaker Org e.V.
  • **
  • Posts: 3556
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Login Redirect - Is it possible to stay on the same page?
« Reply #5 on: July 09, 2008, 12:15:55 AM »
If you read the thread that Matthias pointed. The last line shows what to do.

Code:
Only registered users can see contents. Please click here to Register or Login.
You should be able to get the redirect url with something like this

Code:
Only registered users can see contents. Please click here to Register or Login.
Ruud

Offline fsuk

  • Posts: 127
Re: Login Redirect - Is it possible to stay on the same page?
« Reply #6 on: July 09, 2008, 02:12:06 AM »
I dont have that exact text in my index.php of my template the closest is:

Code:
Only registered users can see contents. Please click here to Register or Login.
See above for the full login/logout form code.

I've tried this but it has no effect:

Code:
Only registered users can see contents. Please click here to Register or Login.
You say deviant like its a bad thing...

Offline Ruud

  • WebsiteBaker Org e.V.
  • **
  • Posts: 3556
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Login Redirect - Is it possible to stay on the same page?
« Reply #7 on: July 09, 2008, 10:05:59 AM »
There are a few php buggies in the code.

$page = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"] ;
and
<form name="login" action="<?php echo LOGIN_URL; ?>?redirect=<?php echo $page; ?>" method="post">

The code below works on my testserver.

Code:
Only registered users can see contents. Please click here to Register or Login.
Succes,

Ruud

Offline fsuk

  • Posts: 127
Re: Login Redirect - Is it possible to stay on the same page?
« Reply #8 on: July 09, 2008, 10:20:05 AM »
ok that works great. Thanks.

Im still quite new to php, but im getting there slowley.

Thanks for your help guys.
You say deviant like its a bad thing...

Offline fsuk

  • Posts: 127
Re: Login Redirect - Is it possible to stay on the same page?
« Reply #9 on: July 09, 2008, 12:11:49 PM »
Ive just tried applying it to the logout and it dosn't work:

Code:
Only registered users can see contents. Please click here to Register or Login.
Is there anyway to apply it to the logout?
You say deviant like its a bad thing...

Offline Ruud

  • WebsiteBaker Org e.V.
  • **
  • Posts: 3556
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Login Redirect - Is it possible to stay on the same page?
« Reply #10 on: July 09, 2008, 12:26:53 PM »
No, not without modifying one of the core files.

If you do that, any upgrade to a next version will at least undo your changes.

Ruud

Offline fsuk

  • Posts: 127
Re: Login Redirect - Is it possible to stay on the same page?
« Reply #11 on: July 09, 2008, 12:28:58 PM »
Ok well i suppose i can leave the logout redirect.

Thanks for your help
You say deviant like its a bad thing...

Offline xoanon

  • Posts: 34
Re: Login Redirect - Is it possible to stay on the same page?
« Reply #12 on: November 21, 2008, 05:43:42 PM »
I just implemented the proposed code and immediately I get permission error message as follows

>>
You don't have permission to access /wb/account/login.php on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

once the redirection code is removed everything works fine !!!!!!!!!

Any Ideas why ????    directory/files permissions are correct...

Offline mxgive

  • Posts: 1
Re: Login Redirect - Is it possible to stay on the same page?
« Reply #13 on: July 09, 2009, 02:23:09 PM »
There are a few php buggies in the code.

$page = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"] ;
and
<form name="login" action="<?php echo LOGIN_URL; ?>?redirect=<?php echo $page; ?>" method="post">

The code below works on my testserver.

Code:
Only registered users can see contents. Please click here to Register or Login.
Succes,

Ruud

If this post is applicable to SMF 1.1.8, pls in which files will I find those codes above

Offline Luisehahne

  • WebsiteBaker Org e.V.
  • **
  • Posts: 4023
  • Gender: Male
    • Webdesign und Entwicklung WebsiteBaker
Re: Login Redirect - Is it possible to stay on the same page?
« Reply #14 on: July 09, 2009, 10:22:34 PM »
until yet i don't test it, what happens on web server with mod_security?

Dietmar
Eric T. Hansen, amerikanischer Buchautor „Nörgeln des Deutschen größte Lust"
Neues Unwort: Schnappatmung

 

postern-length