• 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

Implode array with array of glue strings

Show date difference as "20" instead of "20 years ago"

CodeIgniter 3 is generating a session file on each request, why?

merging two arrays with specified index

args[max_input] woocommerce if statement confused

php mysql + create a friend request system

Why is this PHP array not the same?

Laravel Carbon throws error The format separator does not match

Return multiple values from a function using mysqli_fetch_assoc [closed]

How to get median and quartiles/percentiles of an array in JavaScript (or PHP)?

Last order would be re-order in wooCommerce. How is it possible?

Laravel 5: Is there a non-case sensitive way to sort a collection by an attribute?

Laravel display validation error

get attribute from class not working php 7

Destroy session upon refresh

About Contact Privacy policy Terms and conditions