Setting php session variable on checkbox click

Using jquery we can set php session variable which is quite handy

You would definitely put some input validations

Html part

[code]

<input type="checkbox"
onchange="$.get(‘/set_item.php?push=’+this.checked);">

[/code]

The php part, set_item.php file

[code]

<?php

@session_start();
$_SESSION[‘myVar’] = $_REQUEST[‘push’];
exit;

?>

[/code]

Get Free Email Updates!

Signup now and receive free offers, discounts & coupon codes

I will never give away, trade or sell your email address. You can unsubscribe at any time.

Leave a Reply

Your email address will not be published. Required fields are marked *

CommentLuv badge