Results 1 to 9 of 9
Thread: Why do I need to Login twice??
-
08-11-2014, 10:50 PM #1Junior Guru Wannabe
- Join Date
- Aug 2014
- Posts
- 36
Why do I need to Login twice??
Why do I need to enter the login info and click the login button twice before it actually redirects me to the home page where only users that are logged in can see?
This happens either when I quit and re-open my browser, or when I restart my localhost servers... Basically, when I enter the login info and click login, it just redirects me to back to the login page... And the same goes for the signup script. But if the correct information is entered both times, then it'll log me in. My signup and login scripts go through a redirect page where:
<?php
session_start();
if($_SESSION['username'])
echo'<script type="text/javascript">window.location="home"</script>';
else
echo'<script type="text/javascript">window.location="home"</script>';
?>
I really don't know whats the problem because it always works the second time and however many times I login and out but if the localhost server or web browser was restarted, then it won't.
-
08-12-2014, 03:16 AM #2New Member
- Join Date
- Aug 2014
- Posts
- 4
It sounds like you are not setting the username correctly in the session before loading the redirect page
Try doing the following code before the redirect and seeing if this has been added to the session on the first redirect
PHP Code:print_r($_SESSION);
-
08-12-2014, 04:16 AM #3Web Hosting Master
- Join Date
- Aug 2001
- Posts
- 5,597
Whats the Javascript supposed to do?
-
08-12-2014, 03:20 PM #4Junior Guru Wannabe
- Join Date
- Aug 2014
- Posts
- 36
-
08-13-2014, 03:49 AM #5New Member
- Join Date
- Aug 2014
- Posts
- 4
-
08-13-2014, 07:06 PM #6Junior Guru Wannabe
- Join Date
- Aug 2014
- Posts
- 36
-
08-15-2014, 07:11 AM #7New Member
- Join Date
- Aug 2014
- Posts
- 4
-
08-18-2014, 12:32 PM #8Newbie
- Join Date
- Jul 2014
- Posts
- 24
Yeah, setting the redirect location with Location: url is better. Otherwise, browsers that have JavaScript disabled will not be able to use your site
-
08-18-2014, 01:18 PM #9Web Hosting Master
- Join Date
- Aug 2001
- Posts
- 5,597
Similar Threads
-
Plesk: How to login to SSH with customer login?
By [Axelsson] in forum Hosting Software and Control PanelsReplies: 8Last Post: 02-24-2012, 09:25 PM -
PHPBB-3.0.9 Login integration with external login/reg code
By SunProgrammer in forum Web Design and ContentReplies: 0Last Post: 07-25-2011, 03:31 PM -
website login just like Digg (login with existing account from facebook and Twitter)
By deecoupexpert in forum Web Design and ContentReplies: 2Last Post: 05-19-2011, 07:15 AM -
Can't login to webmail on cpanel vps, redirects back to login page?
By build-a-host in forum VPS HostingReplies: 5Last Post: 01-25-2008, 12:52 PM -
Webpage login form intigration with cpanel login
By mhs in forum Programming DiscussionReplies: 2Last Post: 08-05-2003, 12:13 AM