• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How can I get user id from session in javascript?

javascriptphpcodeigniter


PHP Snippet 1:

<input id="userId" value="<?php $_SESSION['user_id'] ?>" style="display:none">

PHP Snippet 2:

$( document ).ready(function() {
   alert( $('#userId').val() );
   console.log('done');
});

Related Snippets

woocommerce get_order_report_data to show order_item_id

Getting error: CodeIgniterDatabaseBaseResult::getResult in CodeIgniter

Return multiple values from a function using mysqli_fetch_assoc [closed]

Check if user online laravel

Creating live search with AJAX and CodeIgniter

Parameter is not sent to Laravel route in Ajax

Laravel: Why is my variable not being set while it's in the construct function of the controller?

protect images from being copied

Laravel Model save() & update() Not Saving

500 Internal Server Error on Ajax request. Not sure the origin of the problem

PHP array slice from position + attempt to return fixed number of items

Detect emoticons in string

woocommerce_wp_select options array from product attribute terms

php retrieve specific data onclick from database in a list format

How can I get new CSRF token in LARAVEL by using ajax

About Contact Privacy policy Terms and conditions