Welcome! Log In Create A New Profile

Advanced

Topic 5C

Posted by Anonymous User 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
avatar
Mac
Re: Topic 5C
May 15, 2006 06:17PM
I'm amazed you still have GET and not POST, although this is not related to the error you'r egetting....

Your error is related to:
Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct

Have a look in your php.ini file for the section SESSIOns. Look at session.save_path = C:\FoxServ\sessiondata. Make sure this directory exists, for starters.
Re: Topic 5C
May 16, 2006 11:49AM
I do have C:\FoxServ\sessiondata folder

I changed the php.ini file inside the windows directory in 3 places as show below

I still believe that color is not being assigned as the screen background does not change from red to the selected bgcolor

my output is
Warning: open(/tmp\sess_1abb1439b8aa4bb1bbc98d557b8f557f, O_RDWR) failed: No such file or directory (2) in C:\FoxServ\www\StudentPHP\session.php on line 2

Select a background color
Yellow
Blue
Silver
Beige


refresh page, Don't change background color

To other page
Warning: open(/tmp\sess_1abb1439b8aa4bb1bbc98d557b8f557f, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

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




[Session]
; Handler used to store/retrieve data.
session.save_handler = files

; Argument passed to save_handler. In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this
; variable in order to use PHP's session functions.
;
; As of PHP 4.0.1, you can define the path as:
;
; session.save_path = C:\FoxServ\sessiondata.
;
; where N is an integer. Instead of storing all the session files in
; /path, what this will do is use subdirectories N-levels deep, and
; store the session data in those directories. This is useful if you
; or your OS have problems with lots of files in one directory, and is
; a more efficient layout for servers that handle lots of sessions.
;
; NOTE 1: PHP will not create this directory structure automatically.
; You can use the script in the ext/session dir for that purpose.
; NOTE 2: See the section on garbage collection below if you choose to
; use subdirectories for session storage
;
; The file storage module creates files using mode 600 by default.
; You can change that by using
;
; session.save_path = C:\FoxServ\sessiondata.
;
; where MODE is the octal representation of the mode. Note that this
; does not overwrite the process's umask.
;session.save_path = C:\FoxServ\sessiondata.

; Whether to use cookies.
session.use_cookies = 1

; This option enables administrators to make their users invulnerable to
; attacks which involve passing session ids in URLs; defaults to 0.
; session.use_only_cookies = 1

; Name of the session (used as cookie name).
session.name = PHPSESSID

; Initialize session on request startup.
session.auto_start = 0

; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0

session

<?php
session_start();
//session_start("bgcolor"winking smiley;
$_SESSION["bgcolor"];
//$_color['color'];
//session_register ("bgcolor"winking smiley;

if (isset($color)){

switch ($color) {
case "Yellow":
$bgcolor="#FFCC00";
break;
case "Blue":
$bgcolor="#4682B4";
break;
case "Silver":
$bgcolor="#C0C0C0";
break;
case "Beige":
$bgcolor="#FFE4C4";
break;
default:
$bgcolor = "white";
break;
} //end switch
}
if (empty ($color)){
$bgcolor = "Red";
}
?>

<html>
<head><title>Session Example</title></head>
<body bgcolor = '<?php echo $bgcolor; ?>'>

<form method = 'POST' action = 'session.php?<?php echo session_id();?>'>

Select a background color
<br>
<input name='color' TYPE='radio' VALUE='Yellow'> Yellow
<br>
<input name='color' TYPE='radio' VALUE='Blue'> Blue
<br>
<input name='color' TYPE='radio' VALUE='Silver'> Silver
<br>
<input name='color' TYPE='radio' VALUE='Beige'> Beige
<br>
<br>
<input type='submit'value ='Change background color'>
</form>

<a href='session.php?<?php echo session_id();?>'> refresh page, Don't change background color</a>
<br><br>
<a href ='session2.php?<?php echo session_id();?>'>To other page</a>


</body>
</html>




session2
<?php
$_SESSION["bgcolor"];
//session_register ("bgcolor"winking smiley;

if (empty($color)) {
$bgcolor = "Red";
}
?>

<html>
<head><title> Session Example</title></head>
<body bgcolor='<?php echo $bgcolor; ?>'>

What color is my background?

<a href = 'session.php?<?php echo SID;?>'> <br><br>Back to form page</a>
</body>
</html>

Re: Topic 5C
May 17, 2006 11:27AM
Ok.. something is still not right with my session, but i'm working on it (and tearing my hair out at the same time). Just wanted to let you know i havent forgotten about this and i am working on it.
Re: Topic 5C
May 18, 2006 10:04AM
I am a total loss so if you get any answers please post them I will be very greatfull
Re: Topic 5C
May 18, 2006 11:59AM
Completed.
avatar
Mac
Re: Topic 5C
May 18, 2006 01:43PM
Angus

your php.ini file reads

; session.save_path = C:\FoxServ\sessiondata.

The ; in front comments the line out, so there is no part where to save the session files for starters.

You also post color to session.php, but don't grab it with a $_POST.
Re: Topic 5C
May 19, 2006 11:13AM
Thank you Mac

but despite changes to the ini file and a restart every time I am still not winning.

I tried with and withot the full stop at the end of the sessiondata
is this setting correct?
session.cookie_path = / see below where I inserted the string of ? into the post only

I agree with Verity this one is a pain!!!!



my ini file includes

[Session]
; Handler used to store/retrieve data.
session.save_handler = files

; Argument passed to save_handler. In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this
; variable in order to use PHP's session functions.
;
; As of PHP 4.0.1, you can define the path as:
;
session.save_path = C:\FoxServ\sessiondata
;
; where N is an integer. Instead of storing all the session files in
; /path, what this will do is use subdirectories N-levels deep, and
; store the session data in those directories. This is useful if you
; or your OS have problems with lots of files in one directory, and is
; a more efficient layout for servers that handle lots of sessions.
;
; NOTE 1: PHP will not create this directory structure automatically.
; You can use the script in the ext/session dir for that purpose.
; NOTE 2: See the section on garbage collection below if you choose to
; use subdirectories for session storage
;
; The file storage module creates files using mode 600 by default.
; You can change that by using
;
session.save_path = C:\FoxServ\sessiondata
;
; where MODE is the octal representation of the mode. Note that this
; does not overwrite the process's umask.
session.save_path = C:\FoxServ\sessiondata

; Whether to use cookies.
session.use_cookies = 1

; This option enables administrators to make their users invulnerable to
; attacks which involve passing session ids in URLs; defaults to 0.
; session.use_only_cookies = 1

; Name of the session (used as cookie name).
session.name = PHPSESSID

; Initialize session on request startup.
session.auto_start = 0

; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0

; The path for which the cookie is valid.
session.cookie_path = / ????????

; The domain for which the cookie is valid.
session.cookie_domain =

; Handler used to serialize data. php is the standard serializer of PHP.
session.serialize_handler = php

; Define the probability that the 'garbage collection' process is started
; on every session initialization.
; The probability is calculated by using gc_probability/gc_divisor,
; e.g. 1/100 means there is a 1% chance that the GC process starts
; on each request.

session.gc_probability = 1
session.gc_divisor = 100

; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
session.gc_maxlifetime = 1440

; NOTE: If you are using the subdirectory option for storing session files
; (see session.save_path above), then garbage collection does *not*
; happen automatically. You will need to do your own garbage
; collection through a shell script, cron entry, or some other method.
; For example, the following script would is the equivalent of
; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
; cd /path/to/sessions; find -cmin +24 | xargs rm

; PHP 4.2 and less have an undocumented feature/bug that allows you to
; to initialize a session variable in the global scope, albeit register_globals
; is disabled. PHP 4.3 and later will warn you, if this feature is used.
; You can disable the feature and the warning separately. At this time,
; the warning is only displayed, if bug_compat_42 is enabled.

session.bug_compat_42 = 1
session.bug_compat_warn = 1

; Check HTTP Referer to invalidate externally stored URLs containing ids.
; HTTP_REFERER has to contain this substring for the session to be
; considered as valid.
session.referer_check =

; How many bytes to read from the file.
session.entropy_length = 0

; Specified here to create the session id.
session.entropy_file =

;session.entropy_length = 16

;session.entropy_file = /dev/urandom

; Set to {nocache,private,public,} to determine HTTP caching aspects
; or leave this empty to avoid sending anti-caching headers.
session.cache_limiter = nocache

; Document expires after n minutes.
session.cache_expire = 180


session2
<?php
//@extract($_POST);
$color = $_POST[‘color’];
$_SESSION["bgcolor"];
//session_register ("bgcolor"winking smiley;

if (empty($color)) {
$bgcolor = "Red";
}
?>

<html>
<head><title> Session Example</title></head>
<body bgcolor='<?php echo $bgcolor; ?>'>

What color is my background?

<a href = 'session.php?<?php echo SID;?>'> <br><br>Back to form page</a>
</body>
</html>




session
<?php
//@extract($_POST);
$color = $_POST[‘color’];
session_start();
//session_start("bgcolor"winking smiley;
$_SESSION["bgcolor"];
//session_register("bgcolor"winking smiley;

if (isset($color)){

switch ($color) {
case "Yellow":
$bgcolor="#FFCC00";
break;
case "Blue":
$bgcolor="#4682B4";
break;
case "Silver":
$bgcolor="#C0C0C0";
break;
case "Beige":
$bgcolor="#FFE4C4";
break;
default:
$bgcolor = "white";
break;
} //end switch
}
if (empty ($color)){
$bgcolor = "Red";
}
?>

<html>
<head><title>Session Example</title></head>
<body bgcolor = '<?php echo $bgcolor; ?>'>

<form method = 'POST' action = 'session.php?<?php echo session_id();?>'>

Select a background color
<br>
<input name='color' TYPE='radio' VALUE='Yellow'> Yellow
<br>
<input name='color' TYPE='radio' VALUE='Blue'> Blue
<br>
<input name='color' TYPE='radio' VALUE='Silver'> Silver
<br>
<input name='color' TYPE='radio' VALUE='Beige'> Beige
<br>
<br>
<input type='submit'value ='Change background color'>
</form>

<a href='session.php?<?php echo session_id();?>'> refresh page, Don't change background color</a>
<br><br>
<a href ='session2.php?<?php echo session_id();?>'>To other page</a>


</body>
</html>












avatar
Mac
Re: Topic 5C
May 19, 2006 11:38AM
This my session section in my php.ini part.

; Handler used to store/retrieve data.
session.save_handler = files

; Argument passed to save_handler. In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this
; variable in order to use PHP's session functions.
session.save_path = C:\FoxServ\sessiondata

; Whether to use cookies.
session.use_cookies = 1


; Name of the session (used as cookie name).
session.name = PHPSESSID

; Initialize session on request startup.
session.auto_start = 0

; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0

; The path for which the cookie is valid.
session.cookie_path = /

; The domain for which the cookie is valid.
session.cookie_domain =

; Handler used to serialize data. php is the standard serializer of PHP.
session.serialize_handler = php

; Percentual probability that the 'garbage collection' process is started
; on every session initialization.
session.gc_probability = 1

; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
session.gc_maxlifetime = 1440

; Check HTTP Referer to invalidate externally stored URLs containing ids.
; HTTP_REFERER has to contain this substring for the session to be
; considered as valid.
session.referer_check =

; How many bytes to read from the file.
session.entropy_length = 0

; Specified here to create the session id.
session.entropy_file =

;session.entropy_length = 16

;session.entropy_file = /dev/urandom

; Set to {nocache,private,public} to determine HTTP caching aspects.
session.cache_limiter = nocache

; Document expires after n minutes.
session.cache_expire = 180

; use transient sid support if enabled by compiling with --enable-trans-sid.
session.use_trans_sid = 1

url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"

I remember you ignoring what I said about blank spaces etc - remember it could be a combination of factors that causes the problem, so ignore blank space at your peril. And put code like like headers, set_cookie, session_register, session_start etc. right the top of the page. Nothing before it if possible, certainly no blank spaces.

You already have 2 lines before.
//
$color = $_POST[‘color’];
session_start();

I'm not saying that that is where the only problem is, I'm saying a combination of problems could result is your troubles. So start by having removing balnk spaces and having code at the top.
[/b]
Re: Topic 5C
May 23, 2006 08:54AM
Ok.. so its not actually the session i'm having trouble with, its getting background color to stay. My session id is there, and stays no matter where a navigate to. But the colour background doesn't come with it.

Any ideas? This is killing me now because i know its something really silly.
avatar
Mac
Re: Topic 5C
May 23, 2006 11:15AM
Post code.
Sorry, you do not have permission to post/reply in this forum.