I'm using a query string attached to external links to identify vendors visiting my Wordpress site. I need to save the query (currently using $_GET[]) to a session or cookie but am having no luck with either. Is there an easy way to accomplish this? (WP 3.8.2)

FYI I've been through and through other posts but turned up nothing useful...

有帮助吗?

解决方案

Url example: example.com?vendor=something

You can save to session or cookie like that:

$_SESSION['vendor'] = $_GET['vendor'];
setcookie('vendor', $_GET['vendor'], time()+86400); //For 1 day
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top