• 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

Refresh specific HTML content that retrieves data from MySQL

php - add comma thousands separator but remove trailing zeros

Send same name multiple checkbox values via ajax

How to give apache permission to write to home directory?

Changing font color in javascript

unable to load your default controller on Codeigniter

Laravel dosen't connect with Oracle

passwordless LDAP login and get user information using Kerberos ticket in PHP

How to increase the PHP upload limits [duplicate]

Show Custom Data in Woocommerce Order Details Admin Area

How to use React Router with Laravel?

Can't call javascript alert alertify library from PHP

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

PHP array, move keys and values to new array, but mix it up

Message: Set sys_temp_dir in your php.ini after installed composer

About Contact Privacy policy Terms and conditions