|
Posted by Gootes on 03/04/07 15:29
Why are you calling header(); with no params? Try to remove it. try change
} elseif ($_COOKIE['test'] == "hi") { to simple } else {.
Seansan wrote:
> Seansan wrote:
>> Hi,
>>
>> When I run the following in PHP then two cookies are set.
>>
>> ini_set('session.name', 'session-1');
>> session_start();
>> setcookie('session-2', '');
>>
>>
>> Both cookies are being sent to the client, and then to the server (I am
>> sure), but they are not available in $_COOKIE (this array is empty).
>>
>> Why and how can the $_COOKIE variable be empty - this is getting
>> frustrating. Am I missing something? All other global variables are
>> available normally, only $_COOKIE is always empty.
>>
>> (ps. I am viewing the page through plesk site preview over https, and
>> have tried bot secure and normal)
>>
>>
>> kind regards, Seansan
>>
>>
>> Please find ini settings through phpinfo below.
>>
>> Directive Local Value Master Value
>> allow_call_time_pass_reference Off Off
>> allow_url_fopen On On
>> always_populate_raw_post_data Off Off
>> arg_separator.input & &
>> arg_separator.output & &
>> asp_tags Off Off
>> auto_append_file no value no value
>> auto_prepend_file no value no value
>> browscap no value no value
>> default_charset no value no value
>> default_mimetype text/html text/html
>> define_syslog_variables Off Off
>> disable_classes no value no value
>> disable_functions no value no value
>> display_errors Off Off
>> display_startup_errors Off Off
>> doc_root no value no value
>> docref_ext no value no value
>> docref_root no value no value
>> enable_dl On On
>> error_append_string no value no value
>> error_log backend/logs/errors no value
>> error_prepend_string no value no value
>> error_reporting 2047 2047
>> expose_php On On
>> extension_dir /usr/lib/php4 /usr/lib/php4
>> file_uploads On On
>> gpc_order GPC GPC
>> highlight.bg #FFFFFF #FFFFFF
>> highlight.comment #FF8000 #FF8000
>> highlight.default #0000BB #0000BB
>> highlight.html #000000 #000000
>> highlight.keyword #007700 #007700
>> highlight.string #DD0000 #DD0000
>> html_errors On On
>> ignore_repeated_errors Off Off
>> ignore_repeated_source Off Off
>> ignore_user_abort Off Off
>> implicit_flush Off Off
>> include_path .: .:
>> log_errors On On
>> log_errors_max_len 1024 1024
>> magic_quotes_gpc Off Off
>> magic_quotes_runtime Off Off
>> magic_quotes_sybase Off Off
>> max_execution_time 30 30
>> max_input_time 60 60
>> memory_limit 32M 32M
>> open_basedir /var/www/vhosts/domain.nl/httpdocs:/tmp no value
>> output_buffering no value no value
>> output_handler no value no value
>> post_max_size 8M 8M
>> precision 14 14
>> register_argc_argv On On
>> register_globals On Off
>> report_memleaks On On
>> safe_mode On Off
>> safe_mode_exec_dir no value no value
>> safe_mode_gid Off Off
>> safe_mode_include_dir no value no value
>> sendmail_from no value no value
>> sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
>> serialize_precision 100 100
>> short_open_tag On On
>> SMTP localhost localhost
>> smtp_port 25 25
>> sql.safe_mode Off Off
>> track_errors Off Off
>> unserialize_callback_func no value no value
>> upload_max_filesize 2M 2M
>> upload_tmp_dir no value no value
>> user_dir no value no value
>> variables_order EGPCS EGPCS
>> xmlrpc_error_number 0 0
>> xmlrpc_errors Off Off
>> y2k_compliance On On
>
> I always see "This is your first visit"
>
> <?php
> header();
>
> if ($_COOKIE['test'] != "hi") {
> setcookie('test', 'hi');
> echo "This is your first visit";
> }
>
> elseif ($_COOKIE['test'] == "hi") {
> echo "we found the cookie! You have been here before";
> }
>
> ?>
Navigation:
[Reply to this message]
|