Jump to content

[SOLVED] sessions help


runnerjp

Recommended Posts

hey guys gonna try keep this simple as possible lol

 

ok so i have my page set out like so

 

<?php 
require_once('http://www.website.com/settings.php');
checkLogin('1 2');
?>
<?php
echo 'Hello <em><b><u>' . get_username ( $_SESSION['user_id'] ) . '</u></b></em>!<br />You are now logged in.<br /><br />.';	
?>

 

settings has this at the start

<?php
require ( 'http://www.website.com/lib/connection.php' );			// - the connection class needed to operate with mysql
require ( 'http://www.website.com/functions.php' );				// - the functions

 

and functions holds this part of the code that is supposed to work

function checkLogin ( $levels )
{
	session_start ();
	global $db;
	$kt = split ( ' ', $levels );

	if ( ! $_SESSION['logged_in'] ) {

		$access = FALSE;

		if ( isset ( $_COOKIE['cookie_id'] ) ) {//if we have a cookie

			$query =  'SELECT * FROM ' . DBPREFIX . 'users WHERE ID = ' . $db->qstr ( $_COOKIE['cookie_id'] );

			if ( $db->RecordCount ( $query ) == 1 ) {//only one user can match that query
				$row = $db->getRow ( $query );

				//let's see if we pass the validation, no monkey business
				if ( $_COOKIE['authenticate'] == md5 ( getIP () . $row->Password . $_SERVER['USER_AGENT'] ) ) {
					//we set the sessions so we don't repeat this step over and over again
					$_SESSION['user_id'] = $row->ID;				
					$_SESSION['logged_in'] = TRUE;

					//now we check the level access, we might not have the permission
					if ( in_array ( get_level_access ( $_SESSION['user_id'] ), $kt ) ) {
						//we do?! horray!
						$access = TRUE;
					}
				}
			}
		}
	}
	else {			
		$access = FALSE;

		if ( in_array ( get_level_access ( $_SESSION['user_id'] ), $kt ) ) {
			$access = TRUE;
		}
	}

	if ( $access == FALSE ) {
		header('Location: http://website.com/members/index.php');
	}		
}

 

yet im getting the error code Call to undefined function: checklogin()

 

as it works on other pages outside the members folder how comes this does not work??

Link to comment
https://forums.phpfreaks.com/topic/78817-solved-sessions-help/
Share on other sites

but i have used this command before and it worked fine outside of the folder im using?

 

also when correcting it i get this error

<?php 
require_once('http://www.website.com/settings.php');
checkLogin('1 2').;

echo 'Hello <em><b><u>' . get_username ( $_SESSION['user_id'] ) . '</u></b></em>!<br />You are now logged in.<br /><br />.';	
?>

 

Parse error: syntax error, unexpected ';' in /home/runningp/public_html/members/profile.php on line 17

 

i have used require_once('http://www.website.com/settings.php');

checkLogin('1 2');

before and it worked fine :S

 

Link to comment
https://forums.phpfreaks.com/topic/78817-solved-sessions-help/#findComment-398872
Share on other sites

but i have used this command before and it worked fine outside of the folder im using?

 

also when correcting it i get this error

<?php 
require_once('http://www.website.com/settings.php');
checkLogin('1 2').;

echo 'Hello <em><b><u>' . get_username ( $_SESSION['user_id'] ) . '</u></b></em>!<br />You are now logged in.<br /><br />.';	
?>

 

Parse error: syntax error, unexpected ';' in /home/runningp/public_html/members/profile.php on line 17

 

i have used require_once('http://www.website.com/settings.php');

checkLogin('1 2');

before and it worked fine :S

 

 

what is line 17?

 

Link to comment
https://forums.phpfreaks.com/topic/78817-solved-sessions-help/#findComment-398874
Share on other sites

The OP said:

> yet im getting the error code Call to undefined function: checklogin()

 

Does the error handler do a strtolower function on function names?

 

I saw that in his code he posted, he had it correctly capitalized, but I thought maybe he was calling checklogin() from somewhere else too (something that wasn't posted). Oh well...

 

PhREEEk

Link to comment
https://forums.phpfreaks.com/topic/78817-solved-sessions-help/#findComment-398881
Share on other sites

yes but the file im using to call it is in members file and settings is just in route folder

 

<?php
require ( 'http://www.website.com/lib/connection.php' );			// - the connection class needed to operate with mysql
require ( 'http://www.website.com/functions.php' );				// - the functions

 

to

 

<?php
require ( 'lib/connection.php' );			// - the connection class needed to operate with mysql
require ( 'functions.php' );				// - the functions

Link to comment
https://forums.phpfreaks.com/topic/78817-solved-sessions-help/#findComment-398901
Share on other sites

wow ok that just made MAJOR errors

 

Warning: main() [function.main]: open_basedir restriction in effect. File(/lib/connection.php) is not within the allowed path(s): (/home/runningp:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp) in /home/runningp/public_html/settings.php on line 2

 

Warning: main(/lib/connection.php) [function.main]: failed to open stream: Operation not permitted in /home/runningp/public_html/settings.php on line 2

 

Warning: main() [function.main]: open_basedir restriction in effect. File(/lib/connection.php) is not within the allowed path(s): (/home/runningp:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp) in /home/runningp/public_html/settings.php on line 2

 

Warning: main(/lib/connection.php) [function.main]: failed to open stream: Operation not permitted in /home/runningp/public_html/settings.php on line 2

 

Fatal error: main() [function.require]: Failed opening required '/lib/connection.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/runningp/public_html/settings.php on line 2

Link to comment
https://forums.phpfreaks.com/topic/78817-solved-sessions-help/#findComment-398904
Share on other sites

wow ok that just made MAJOR errors

 

Warning: main() [function.main]: open_basedir restriction in effect. File(/lib/connection.php) is not within the allowed path(s): (/home/runningp:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp) in /home/runningp/public_html/settings.php on line 2

 

Warning: main(/lib/connection.php) [function.main]: failed to open stream: Operation not permitted in /home/runningp/public_html/settings.php on line 2

 

Warning: main() [function.main]: open_basedir restriction in effect. File(/lib/connection.php) is not within the allowed path(s): (/home/runningp:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp) in /home/runningp/public_html/settings.php on line 2

 

Warning: main(/lib/connection.php) [function.main]: failed to open stream: Operation not permitted in /home/runningp/public_html/settings.php on line 2

 

Fatal error: main() [function.require]: Failed opening required '/lib/connection.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/runningp/public_html/settings.php on line 2

 

Might just be how i included the files, since I don't know the exact root.

 

Try putting those lines I edited right on your page where your using your functions.

Link to comment
https://forums.phpfreaks.com/topic/78817-solved-sessions-help/#findComment-398906
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.