html - Session data doesn't persist - php configuration issue? -
i have next code snippet in file:-
session_start(); $_session['frompanel'] = "abcd"; <form method="post" action="/m/xyz.php"> <div class="text inputcaption"><b><?= _("email")?></b></div> <input type="email" name="username" value="<?=$objmobile->getemail()?>"> </div> </form>
when file xyz.php
called on post request, $_session
array coming empty. please note session_start();
given in xyz.php
before printing session array. why session array getting empty itself. can help me?
code xyz.php:
<?php session_start(); print "<pre>"; print_r($_session); print "<post>"; ?>
please find session settings obtained through phpinfo();
|---------------------------------|---------------------|---------------------| | session back upwards | enabled | | | registered | save handlers | files user | | registered | serializer handlers | php php_binary wddx | | | | | |---------------------------------|---------------------|---------------------| | directive | local value | master value | |---------------------------------|---------------------|---------------------| | session.auto_start | off | off | | session.bug_compat_42 | on | on | | session.bug_compat_warn | on | on | | session.cache_expire | 180 | 180 | | session.cache_limiter | nocache | nocache | | session.cookie_domain | no value | no value | | session.cookie_httponly | off | off | | session.cookie_lifetime | 0 | 0 | | session.cookie_path | / | / | | session.cookie_secure | off | off | | session.entropy_file | no value | no value | | session.entropy_length | 0 | 0 | | session.gc_divisor | 100 | 100 | | session.gc_maxlifetime | 1440 | 1440 | | session.gc_probability | 1 | 1 | | session.hash_bits_per_character | 4 | 4 | | session.hash_function | 0 | 0 | | session.name | phpsessid | phpsessid | | session.referer_check | no value | no value | | session.save_handler | files | files | | session.save_path | c:\windows\temp | c:\windows\temp | | session.serialize_handler | php | php | | session.use_cookies | on | on | | session.use_only_cookies | off | off | | session.use_trans_sid | 0 | 0 | |---------------------------------|---------------------|---------------------|
on enabling error_reporting, next warnings seen:
warning: unknown: open(c:\windows\temp\sess_1037ca26d3ebb62017eddc9cbfb107e2, o_rdwr) failed: invalid argument (22) in unknown on line 0 warning: unknown: failed write session info (files). please verify current setting of session.save_path right (c:\windows\temp) in unknown on line 0
i converted snippet working code , runs charm. please provide finish non-working illustration can help you.
a.php:
<?php session_start(); $_session['frompanel'] = "abcd"; ?> <form method="post" action="./b.php"> <input type="email" name="username" value="john@example.com"> </form>
b.php:
<?php session_start(); var_dump( $_session['frompanel'] ); var_dump( $_post['username'] ); echo '<a href="./_test.php">back form</a>';
result output after sending form (with come in in input):
string 'abcd' (length=4) string 'john@example.com' (length=16) form
n.b: utilize <label for="id-of-form">caption</label>
instead of <div class="text inputcaption"></div>
php html session post
No comments:
Post a Comment