Hello.
It seems that I cannot play around with cookies at all! Maybe I'm doing something wrong, but
here's my php.ini cookie section :
[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.
session.save_path = C:\PHP\sessiondata ; argument passed to save_handler
; 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 = localhost
; 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
and here's the code for using cookies:
<?php
// Check for the $LastTime cookie variable.
if ( !empty( $LastTime ) )
{
$aMessage = "The last time you visited was ";
$aMessage .= date( "d F Y", $LastTime );
$aMessage .= " at ";
$aMessage .= date( "h:i:s a", $LastTime );
}
else
{
$aMessage = "You have not visited in the past ";
$aMessage .= "two weeks.";
}
// Set the $LastTime cookie that will be valid for
// two weeks
$aTwoWeeks = time() + ( 60 * 60 * 24 * 14 );
setcookie( "LastTime", time(), $aTwoWeeks );
// check for the extremely important cookie array values
$aValMessage = "";
if ( !empty( $CookieArray ) )
{
$aValMessage = "Values: " . $CookieArray[0];
$aValMessage .= ", " . $CookieArray[1];
$aStartValue = $CookieArray[1] + 1;
}
else
{
$aValMessage = "The Values are not available!";
$aStartValue = 0;
}
// delete the extremely imporant cookie array values
setcookie( "CookieArray[0]" );
setcookie( "CookieArray[1]" );
// add the extremely imporant cookie array values
setcookie( "CookieArray[0]", $aStartValue, $aTwoWeeks );
setcookie( "CookieArray[1]", $aStartValue + 1, $aTwoWeeks );
?>
Needles to say that cookies work just fine but if written here in javascript.
I use: W2K, Apache2, PHP4 (cgi-binary), MySQL (if neccesary).
Where am I wrong here? Help!
It seems that I cannot play around with cookies at all! Maybe I'm doing something wrong, but
here's my php.ini cookie section :
[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.
session.save_path = C:\PHP\sessiondata ; argument passed to save_handler
; 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 = localhost
; 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
and here's the code for using cookies:
<?php
// Check for the $LastTime cookie variable.
if ( !empty( $LastTime ) )
{
$aMessage = "The last time you visited was ";
$aMessage .= date( "d F Y", $LastTime );
$aMessage .= " at ";
$aMessage .= date( "h:i:s a", $LastTime );
}
else
{
$aMessage = "You have not visited in the past ";
$aMessage .= "two weeks.";
}
// Set the $LastTime cookie that will be valid for
// two weeks
$aTwoWeeks = time() + ( 60 * 60 * 24 * 14 );
setcookie( "LastTime", time(), $aTwoWeeks );
// check for the extremely important cookie array values
$aValMessage = "";
if ( !empty( $CookieArray ) )
{
$aValMessage = "Values: " . $CookieArray[0];
$aValMessage .= ", " . $CookieArray[1];
$aStartValue = $CookieArray[1] + 1;
}
else
{
$aValMessage = "The Values are not available!";
$aStartValue = 0;
}
// delete the extremely imporant cookie array values
setcookie( "CookieArray[0]" );
setcookie( "CookieArray[1]" );
// add the extremely imporant cookie array values
setcookie( "CookieArray[0]", $aStartValue, $aTwoWeeks );
setcookie( "CookieArray[1]", $aStartValue + 1, $aTwoWeeks );
?>
Needles to say that cookies work just fine but if written here in javascript.
I use: W2K, Apache2, PHP4 (cgi-binary), MySQL (if neccesary).
Where am I wrong here? Help!