我已经可以创建动态页面,并且可以正常工作,但是登录页面加载速度非常慢。
我真的很想得到一些帮助。以下是我的网站的功能。
让我们从以下链接开始http://example.com/search.php
:
<?php
session_start();
//(pretend there is code here that gets, decodes, and displays data from an api)
$title = $titleFromApi;
$a = $dataFromApi;
$_SESSION['storeTitle'] = $title; // stores 'title' in a session variable
$_SESSION['store_a'] = $a; // stores 'a' in a session variable
echo '<a href="http://example.com/'. $a .'/' . $title .'> ' . $title . '</a>';
// the line above is a clickable link that will take them to the landing page
?>
现在这里是登录页面 ( http://example.com/$a/$title
):
<?php
session_start();
$al = $_SESSION['store_a']; // stores session variable in new variable 'al'
$getter = 'http://api.somewebsite.com/dev/' . $al . '/get_these_variables';
// the line above gets data from an api using variable 'al'
// (pretend that there is code here that decodes the data)
// the code below displays the data retrieved from the api
foreach($data as $entry){
echo '
<div>
' . $entry['decoded_data_1']
. '
</div>
<div>
' . $entry['decoded_data_2'] // and so on
. '
</div>
'; // ends echo
}
?>
我今天刚刚了解了会话(我认为它会使事情变得更快);之前,我将数据从 search.php 发送到地址栏中,然后在登录页面上读取它以携带变量(畏缩,我知道,我对 php 和一般开发都很陌生)。登陆页面的页面加载速度没有改变。