• 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

Display the WooCommerce product price inside a custom function

With doctrine ODM, can I embed many subdocuments in a main document?

Laravel Collections. Is there some kind of assertStructure method?

RuntimeException: Unable to create the cache directory (/var/www/sonata/app/cache/dev)

jQuery Ajax Post with data

IlluminateDatabaseQueryException: SQLSTATE[HY000]: General error: 1 no such table - In clone project

Sync Records With Default Values in Pivot Tables, Call to undefined method syncWithPivotDefaults()

How to downgrade or install a specific version of Composer?

hidden INPUT value not available in $_POST

printing all running session variable in laravel 5.1

Make certain characters of a word from string bold

Check if my GET request has Header: Token

Sort a multidimensional array by integer inside of a string value which is two levels down

Apply session id from request header

Trying to iterate over a mongodb cursor twice - failing

About Contact Privacy policy Terms and conditions