• 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

Using spatie/media-library, how to rename a collection of uploaded files?

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

PHP: Calling MySQL Stored Procedure with Both INPUT AND OUTPUT Parameters (NOT "INOUT")

how to hide previous markers when new markers added in google map javascript api

"properties should not be accessed directly" issue during WooCommerce 3.0 checkout

Adding the custom page with add_menu_page function on Wordpress

Transfer data between JavaScript and PHP through JSON

How to install PHP composer inside a docker container

php echo remove slashes from url [duplicate]

Add restriction to WooCommerce coupons by allowed user ID

How can I remove the "Advanced" panel of all blocks in WordPress block editor?

laravel MVC execution flow

WHERE IN array binding in DB::raw laravel 5.4

using random function but it's displaying duplicates

CodeIgniter force_download is not working

About Contact Privacy policy Terms and conditions