php - Can't access session variables between 2 files -
i'm unable access session variables session_start()
on both files.
file1.php
<?php session_start(); ... if($responsecode == 1) { $_session['card_id'] = $_post['card_id']; $_session['password'] = $_post['password']; print '<script type="text/javascript">'; print 'window.location = "http://domain.com/file2.php";'; print '</script>'; } ?>
file2.php
<?php session_start(); $account = getaccount(); echo "document.write('$account')"; function getaccount() { $card_id = $_session['card_id']; $string = "card = " . $card_id ; return $string; } ?>
file1.php curl request and, if succeeds, redirects file2.php. however, see card :
without card_id entered.
it not work because www considered subdomain, , hence session not persist. can fix in 2 ways -
which consider better way, use htaccess redirect non www urls www urls, better seo
check php manual on how set session across multiple subdomains.
this post explains how www considered subdomain, if curious.
Comments
Post a Comment