Strange occurence with Session Variables.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
timcadieux
Forum Newbie
Posts: 2
Joined: Thu Oct 13, 2011 7:56 am

Strange occurence with Session Variables.

Post by timcadieux »

First off, the below has been working without issue for 4 years now.

I have a Login page that accepts a username and password. I execute the query and set credentials into Session variable like below, this has always worked.

Code: Select all

	if($row= mysql_fetch_array($result)){
			//Login Successful
			
			$_SESSION['SESS_ENABLED'] = 'Authenticated';
			
			session_write_close();
			header("location: index.php");
			exit();
		}else {
			//Login failed
			header("location: login-failed.php");
			exit();
		}
On my Index.php I check for Credentials, for some reason my IF statement now fails. I checked the Sessions on the Login page and the Exist.

Code: Select all

	if(!isset($_SESSION['SESS_ENABLED']) || (trim($_SESSION['SESS_ENABLED']) == '')) {   
		header("location: access-denied.php");
		exit();

	}
The only thing that I know has changed was that the Php was upgraded recently so that WordPress could be run. Ideas anyone?
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: Strange occurence with Session Variables.

Post by Eric! »

Are you now running this login inside a WordPress template? You might try to var_dump($_SESSION) to see if WordPress is resetting your session data variables or changing your session ID.
timcadieux
Forum Newbie
Posts: 2
Joined: Thu Oct 13, 2011 7:56 am

Re: Strange occurence with Session Variables.

Post by timcadieux »

Sorry, I forgot to mention, this folder works separately from WordPress. They run in separate subfolders
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Strange occurence with Session Variables.

Post by pickle »

They would still use the same php.ini file. Perhaps something has changed in that file which affects how sessions are handled. Specifically session.auto_start might have been turned off - any number of other session settings could be messing you up as well.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply