PHP <a href="click" value="" to="" cookie=""

时间:2016-08-08 07:59:46

标签: php cookies menu

="" For a site I use one big PHP file wich generate all the pages, I use url transfer for the menu choice and that's what I want to change.

<li><a href="Index.php?s=I">Home<br></a></li>
<li><a href="Index.php?s=Z">About<br></a></li>

I want to loose the ?s=Z from the URL and pass the value 'Z' to a cookie when clicked and then reload the PHP file, read the cookie, and generate the page "About".

I was thinking and playing with "onclick", but this didn't work.

Regards,

Marco

1 个答案:

答案 0 :(得分:0)

在另一个问题的帮助下我也解决了这个问题,这是一个解决方法,但它可以解决问题。

基本上,解决方案是查看URL末尾是否有VAR。

如果是这样,将VAR放入cookie并重新加载没有URL VAR的页面。 重新加载后,读取cookie并执行菜单选项。