So I want to retrieve the data stored in a <input type='text'>
tag, and then store it in the $_SESSION
array on my server.
I'm using a method of sending a GET request with ajax, then assign the value from $_GET
to $_SESSION
, so I can use the session value later.
The AJAX get request:
var xhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
console.log('Sending email address to system')
xhttp.open('GET','database.php?email='+email_address, false)
xhttp.send()
And then in database.php
:
if(isset($_GET['email'])){
$_SESSION['email'] = $_GET['email'];
}
Is there an easier way to do this? Some kind of http request that just stores that data into $_SESSION
directly instead of using $_GET?
in the middle?