Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 26th, 2004, 06:12 AM
Authorized User
 
Join Date: Feb 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to knight
Default Session problem

i test the following script


<?php
$config_use_sessions = TRUE;
session_start();
if($_SESSION['logged_in'] !== true)
{
Header('Location: login_page.php');
}// valid user's only page here:
?>


but browser say the erros below
Warning: session_start(): open(D:\WINNT\PHP\sessiondata\sess_9ba6395c09f620f 8202e20f22f22ccab, O_RDWR) failed: Permission denied (13) in d:\inetpub\wwwroot\cutenews\ab.php on line 10

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at d:\inetpub\wwwroot\cutenews\ab.php:8) in d:\inetpub\wwwroot\cutenews\ab.php on line 10

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at d:\inetpub\wwwroot\cutenews\ab.php:8) in d:\inetpub\wwwroot\cutenews\ab.php on line 10

Notice: Undefined index: logged_in in d:\inetpub\wwwroot\cutenews\ab.php on line 11

Warning: Cannot modify header information - headers already sent by (output started at d:\inetpub\wwwroot\cutenews\ab.php:8) in d:\inetpub\wwwroot\cutenews\ab.php on line 13

Warning: Unknown(): open(D:\WINNT\PHP\sessiondata\sess_9ba6395c09f620f 8202e20f22f22ccab, O_RDWR) failed: Permission denied (13) 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 (D:\WINNT\PHP\sessiondata) in Unknown on line 0


what is the problem pls tell me




 
Old February 26th, 2004, 07:07 AM
Authorized User
 
Join Date: Sep 2003
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

try the following and see if ti helps.
Code:
<?php 
    $config_use_sessions = TRUE;  
    session_start();
    if(!isset($_SESSION['logged_in']))
    {    
        header('location: login_page.php');
    }// valid user's only page here:
?>
PHP is case sensitive and header was written as Header, as was Location. Also !== true, as far as I am aware (And I may be wrong) is invalid syntax in PHP. it is true that "==" tests for equivalence, but I don't think that you can use it with the not operand "!".

HTH

---
David Thorne, Student
UK
 
Old February 26th, 2004, 03:13 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Quote:
quote:Originally posted by CFerthorney

PHP is case sensitive and header was written as Header, as was Location. Also !== true, as far as I am aware (And I may be wrong) is invalid syntax in PHP. it is true that "==" tests for equivalence, but I don't think that you can use it with the not operand "!".
None of that is true.

Function names are not case-sensitive in PHP (Variables and Constants are).

The '!==' operator is valid, it means not identical whereas '===' means identical. This operator exists because '==' is a less strict comparison, e.g. not case sensitive, FALSE == 0 is TRUE.

See http://www.php.net/manual/en/languag...comparison.php

AND

http://www.php.net/manual/en/types.comparisons.php

The latter shows contrasts and comparisons between the '==' operator and the '===' operator.

'Location' in the call to headers is most generally capitalized, but, this is not a rule.

Onto Knight's problem...

Warning: session_start(): open(D:\WINNT\PHP\sessiondata\sess_9ba6395c09f620f 8202e20f22f22ccab, O_RDWR) failed: Permission denied (13) in d:\inetpub\wwwroot\cutenews\ab.php on line 10

    Well the error says permission denied. Therefore, you have a file permissions error. PHP does not have enough permissions to access the file. Is PHP installed in the WINNT directory? Have a look at this post: http://p2p.wrox.com/topic.asp?TOPIC_ID=8169. If that post doesn't do anything to answer your questions then come back to us.

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at d:\inetpub\wwwroot\cutenews\ab.php:8) in d:\inetpub\wwwroot\cutenews\ab.php on line 10
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at d:\inetpub\wwwroot\cutenews\ab.php:8) in d:\inetpub\wwwroot\cutenews\ab.php on line 10

    These are domino effect errors, output directly because of the first error.

Notice: Undefined index: logged_in in d:\inetpub\wwwroot\cutenews\ab.php on line 11

    This one says $_SESSION['logged_in'] is not a defined variable. Perhaps you should use if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] == true) isset() checks that it exists first.

Warning: Cannot modify header information - headers already sent by (output started at d:\inetpub\wwwroot\cutenews\ab.php:8) in d:\inetpub\wwwroot\cutenews\ab.php on line 13

    Correct the last error about the variable not existing and this one will go away.

Warning: Unknown(): open(D:\WINNT\PHP\sessiondata\sess_9ba6395c09f620f 8202e20f22f22ccab, O_RDWR) failed: Permission denied (13) 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 (D:\WINNT\PHP\sessiondata) in Unknown on line 0

    Again, another permissions error, do what the error says, check the session.save_path directive in php.ini and that PHP has permission to access the files in that directory.

hth,
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
 
Old February 26th, 2004, 06:22 PM
Authorized User
 
Join Date: Sep 2003
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What can I say other than sorry! I did say I might be wrong (Happens surprisingly frequently) "knight" I am sorry. However I do use isset() often, and as Rich says, it is used to check for existence of a variable and might come in useful. Hope I didn't cause too much inconvenience. I'll check what I am talking about form now on!

---
David Thorne, Student
UK





Similar Threads
Thread Thread Starter Forum Replies Last Post
Session Out Problem kasipandian J2EE 3 March 21st, 2008 03:35 PM
session problem MunishBhatia ASP.NET 2.0 Professional 9 October 6th, 2007 04:06 AM
Session problem abdulweb General .NET 3 August 27th, 2007 08:01 PM
session and cookie problem (empty session file) msincan BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 February 27th, 2005 05:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.