• 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 redirect after add-to-cart error

How to programmatically find public properties of a class from inside one of it's methods

Sum column values from multiple arrays

How to write PHP in XSLT

PHPExcel file download using AJAX call

Only on Firefox "Loading failed for the <script> with source"

Adding one microsecond to Datetime object in PHP

Can't find vendor/autoload.php for Ratchet

How to get the survey List from surveygizmo API in the Postman?(Trial Version)

php curl_exec() Connection refused when retrieving a remote image

Composer fails with kylekatarnls/update-helper on new homestead

Unit (real unit test) of test laravel relationship

Laravel - Browser displays message again when I press back button

Laravel s3 upload file with metadata using pre-signed url

PHP DOTENV unable to load env vars

About Contact Privacy policy Terms and conditions