Reputation: 79666
is it possible to create session variables with jquery or javascript or do i have to use ajax to call a php that does that?
Upvotes: 2
Views: 7358
Reputation: 1
Try with this:
<td><?php echo get_tracking_code($borrower->id) ?></td>
<td><?php echo ucwords(strtolower("{$borrower->name} {$borrower->name_middle} {$borrower->name_last}")); ?></td>
<td><?php echo get_purpose($borrower->initial_loan_purpose); ?></td>
<td>Php <?php echo number_format($borrower->initial_loan_amount); ?></td>
<td><?php echo get_location($borrower->location); ?></td>
<td><?php echo $borrower->number_claimed_by_lenders; ?></td>
Upvotes: 0
Reputation: 22527
You can just use php to create a session variable, no javascript required.
<?php
session_start();
$_SESSION['uniquely'] = microtime(true);
?>
I suppose if you wanted to create a session when a user hovered over an image, or clicked on a link, you could use jquery to make an ajax call to set the session.
Thoughts?
Upvotes: 1
Reputation: 268324
You'll need to use a server-request. Javascript operates only on the client, and session data is stored on the server.
// example of passing variable 'name' to server-script for session-data-storage
$.post("createSession.php", {"name":"jonathan"}, function(results) {
alert(results); // alerts 'Updated'
});
And on the server, something like:
session_start();
$_SESSION["name"] = $_POST["name"];
print "Updated"; // What will be passed to Javascript "alert" command.
Upvotes: 8