WordPress PHP $ _SESSION

时间:2018-07-24 15:08:08

标签: php wordpress

我正在使用PHP为我的网站编写一个登录页面。我在本地计算机上开发了它,但没有任何问题,但是我将它放在Wordpress上,由于$ _SESSION没有键 'UserName' < / strong>。

我调查了这个问题,发现由于我df1 = structure(list(CS1 = c(0.275452524610988, 0.0890234670704012, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA ), CS2 = c(0.273041018387553, 0.158963204640203, 0.107973506559674, 0.127130301872373, 0.194176156840133, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), CS3 = c(0.13740676993689, 0.109451540195342, 0.142863368925692, 0.14583878810548, 0.163760683760684, 0.144456538640958, 0.0675847193993944, 0.14371051120046, 0.173233830845771, 0.176593446164926, 0.161520678140252, 0.15704679566351, 0.15038404968132, 0.111057167131934, 0.090005047955578, 0.0904423812124522, 0.139732920456745, 0.101917044266295, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA ), CS4 = c(0.180049261083744, 0.210920756262371, 0.207122726108122, 0.102897135416667, 0.0978761658613327, 0.203262051467923, 0.45636403605188, 0.14423587969798, 0.166896927831303, 0.152883086450749, 0.258352200019687, 0.0430782684739834, 0.167648827420325, 0.0810183353119641, 0.25995907837381, 0.11673133987674, 0.110546066252588, 0.130632135895294, 0.142066731454487, 0.0756522704563118, 0.303907946157186, 0.159501557632399, 0.170402871958516, 0.133117551861115, 0.155054586700695, 0.164944275582574, 0.223909531502423, 0.160357391800266, 0.257635675220867, 0.15363303711448, 0.226395631067961, 0.0953366226325004, 0.167523252469077, 0.161264071612641), CS6 = c(0.174656417423713, 0.180655066530195, 0.038575363525719, 0.140051238257899, 0.200724929520741, 0.159254670224933, 0.16012350077188, 0.176349710442742, 0.163041789128746, 0.159630016410562, 0.194189328743546, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), CS7 = c(0.161839193508729, 0.119446786979255, 0.186711807024968, 0.0900905700586042, 0.221011032438663, 0.0524430272906312, 0.214230867673407, 0.109561723342511, 0.191344988748485, 0.138885983263598, 0.19734564339296, 0.111221877946922, 0.240647749220027, 0.182876881322477, 0.171344685848503, 0.183018867924528, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), CS8 = c(0.208645229309436, 0.168562833310543, 0.161180007515971, 0.122041517916171, 0.133028106320743, 0.249202264539372, 0.194792833146697, 0.157660991857883, 0.105321703956516, 0.102024877061036, 0.0838767042086544, 0.311601536304335, 0.191905094207955, 0.127657464043644, 0.061887744376708, 0.169011882426517, 0.19027015154843, 0.159290431179593, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA ), CS9 = c(0.111283891547049, 0.123824130879346, 0.20258885476086, 0.150561330561331, 0.158708927013667, 0.203820631409612, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), CS10 = c(0.163579343508258, 0.184119010819165, 0.0385607528369776, 0.151343315280875, 0.110706817231284, 0.104659986379998, 0.205260047281324, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)), row.names = c(NA, -34L), class = c("tbl_df", "tbl", "data.frame")) df2 = structure(list(CS1 = c(7.1855827246745, -2.89023467070401, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), CS2 = c(14.4918811881188, 7.40119630233823, 5.52194624888549, 2.14197554451662, 8.22580366152515, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), CS3 = c(9.75146299483649, 4.84006010518407, 7.79873610808455, 11.9482326538246, 9.54301117685733, 8.90216140569118, 4.41407773030818, 11.1924181504882, 13.332504145937, 9.59668707238027, 12.8002226217998, 8.91395636064224, 7.68370648798823, 4.97487559169802, -0.302675416456332, 3.92422173675587, 5.21019289078124, 1.94964563727199, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), CS4 = c(10.5336382828994, 12.2885809842332, 12.5569049449142, 5.01982421875, 3.20047196314192, 9.04392895976803, 20.0755330841943, 4.80978613911503, 5.8746591528813, 6.68753870616788, 10.1209371001083, -0.944521206821163, 9.55786730807777, 0.931829573934837, 13.6828929810515, 2.253868979685, 6.06061076604555, 2.20153160679477, 2.4557045675413, 2.63630509603642, 9.88050369083804, 0.0527677929547089, 6.48542746975137, 1.41274091510961, 7.29614348504183, 7.68493269648285, 11.5562548289668, 7.19918889804195, 15.3076146403029, -0.0899111343439618, 10.3047330097087, 1.39891771446761, 7.78885799213731, 6.10031194900312 ), CS6 = c(4.1787095271372, 4.62118730808597, -0.587060406123888, 5.64545972103615, 7.99747617129816, 9.49651162790698, 4.8287376796105, 7.29071548664301, 5.89087530826661, 5.75097717439953, 6.74011703958692, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), CS7 = c(4.71177772313745, 1.37851239669421, -3.13076597545493, 2.24620848872314, -0.832965585377901, -0.0889243177342196, 10.0609163040696, 1.40906317434333, 4.13460273498356, 2.71950836820084, 8.28693979611464, 4.9104674659841, 10.7405437527856, 13.4829015544041, 4.56230182031709, 0.759141184124919, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), CS8 = c(15.3824986821297, 11.5551620402024, 9.1133659025429, 4.7955573185244, 8.96281317563271, 18.8155944415852, 8.72687569988802, 7.86902294596595, 6.24227025660473, 4.60072317037894, 3.37021339656194, 12.2052673291471, 7.98692719237032, 2.45028930401719, 0.815415878354706, 11.8678236397749, 8.01842741049857, 7.1366049462644, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), CS9 = c(3.4109649122807, 5.76513292433538, 13.5378236068451, 5.73596673596674, 4.87345158476301, 21.4396541323145, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), CS10 = c(5.11039096801171, 5.42426584234931, 1.2306670357044, 9.22986088988, 2.97189460476788, 5.26471446638778, 7.09148936170213, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)), row.names = c(NA, -34L), class = c("tbl_df", "tbl", "data.frame")) 返回print_r($_SESSION)时,$ _ SESSION数据未保存/设置。如何在Wordpress上使用Array()

这是我index.php页面的顶部

$_SESSION

在login.php上(设置信息的内容)

if (!session_id()) 
session_start();

if (!isset($_SESSION['UserName'])) {
    header("Location: login.php");
}

我认为wordpress的做法有所不同。有人可以解释。

0 个答案:

没有答案