• 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

Reducing authentication calls on external API (Laravel 5.6)

SQL to convert multiple rows into a single row of variable length

HTML + PHP + PHPMAILER

Do I need to install `fxp/composer-asset-plugin` if I'm not doing front-end development

How can I create a Download Page with post php method?

Applying programmatically a coupon to an Order in WooCommerce3

SMTP "Error: DATA not accepted from server!" Opencart 2.3 on InMotionHosting

How can I create a Download Page with post php method?

How to access a var with "-" in PHP [duplicate]

curl returning 301 error after migrating to https

Center point of multiple gps coordinates with php

PHP each() function replacement

Chunk and transpose a flat array into rows with a specific number of columns

html-php form submission after validation through JavaScript [closed]

Twig - How to check if variable is a number / integer

About Contact Privacy policy Terms and conditions