I want to implement a code like this however i am getting an error as expected does anybody have any other way to do this or solve my error and make the code work. I have read that this can be done with AJAX but my teacher has forbidden me from using a language other than PHP javascript and html.
<html>
<body>
<?php
$user = "<script language='JavaScript'>var n=sessionStorage.getItem('user');document.write(n);</script>";
//do something with $user
?>
</body
</html>
You can not retrieve sessionStorage or localStorage data (that exists on client) on server (PHP in you example). You have several options:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.