Sessions?

stupid sessions

Page 1 of 1

3 Replies - 2120 Views - Last Post: 06 March 2009 - 05:24 AM Rate Topic: -----

#1 Elemental_1_1  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 114
  • Joined: 22-January 09

Sessions?

Post icon  Posted 06 March 2009 - 04:36 AM

AHHH!!! I've finally installed PHP and everything, but there sessions are bugging me, because I keep getting these errors

Warning: session_start() [function.session-start]: open(C:\windows emp\sess_31531ff6470dbdb2b97be031211a0365, O_RDWR) failed: Invalid argument (22) in C:\inetpub\wwwroot\login.php on line 3

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\inetpub\wwwroot\login.php:3) in C:\inetpub\wwwroot\login.php on line 3

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\inetpub\wwwroot\login.php:3) in C:\inetpub\wwwroot\login.php on line 3

Warning: Unknown: open(C:\windows emp\sess_31531ff6470dbdb2b97be031211a0365, O_RDWR) failed: Invalid argument (22) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (C:\windows emp) in Unknown on line 0

its really annoys me, here is my php code (I tried doing session_save_path() at the start, no difference)

<?php
session_save_path("C:\windows\temp");
	session_start();
	if($_POST) {
		require_once 'config.php';
		$username = $_POST['username'];
		$password = $_POST['password'];		
		$conn = mysql_connect($dbhost,$dbuser,$dbpass)
			or die ('Error connecting to mysql');
		mysql_select_db($dbname);
		$query = sprintf("SELECT COUNT(id) FROM users WHERE UPPER(username) = UPPER('%s') AND password='%s'",
			mysql_real_escape_string($username),
			mysql_real_escape_string(md5($password)));
		$result = mysql_query($query);
		list($count) = mysql_fetch_row($result);
		if($count == 1) {
			$_SESSION['authenticated'] = true;
			$_SESSION['username'] = $username;
			$query = sprintf("UPDATE users SET last_login = NOW() WHERE UPPER(username) = UPPER('%s') AND password = '%s'",
				mysql_real_escape_string($username),
				mysql_real_escape_string(md5($password)));
			mysql_query($query);
			$query = sprintf("SELECT is_admin FROM users WHERE UPPER(username) = UPPER('%s') AND password='%s'",
				mysql_real_escape_string($username),
				mysql_real_escape_string(md5($password)));
			$result = mysql_query($query);
			list($is_admin) = mysql_fetch_row($result);
			if($is_admin == 1) {
				header('Location:admin.php');			
			} else {
				header('Location:index.php');				
			}
		} else {	?>
<span style='color:red'>Error: that username and password combination does not match any currently within our database.</span>
<?php	}
	}
?>
<form action='login.php' method='post'>
Username: <input type='text' name='username' /><br />
Password: <input type='password' name='password' /><br />
<input type='submit' value='Login' />
</form>


Also the session.save_path in my php.ini is "c:/windows/temp" aswell.

Any help?

Is This A Good Question/Topic? 0
  • +

Replies To: Sessions?

#2 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 543
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: Sessions?

Posted 06 March 2009 - 04:58 AM

session_save_path("C:\windows\temp"); needs to be session_save_path("C:\windows\\temp");.

Also, session.save path in your php.ini file should be "c:\\windows\\temp". You have to escape backslashes or it'll think you're escaping the characters in front of them.

This post has been edited by Valek: 06 March 2009 - 05:07 AM

Was This Post Helpful? 0
  • +
  • -

#3 Elemental_1_1  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 114
  • Joined: 22-January 09

Re: Sessions?

Posted 06 March 2009 - 05:22 AM

View PostValek, on 6 Mar, 2009 - 03:58 AM, said:

session_save_path("C:\windows\temp"); needs to be session_save_path("C:\windows\\temp");.

Also, session.save path in your php.ini file should be "c:\\windows\\temp". You have to escape backslashes or it'll think you're escaping the characters in front of them.

thankyou! it worked
Was This Post Helpful? 0
  • +
  • -

#4 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 543
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: Sessions?

Posted 06 March 2009 - 05:24 AM

No problem :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1