• 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

How to get monthly wise data in laravel

CodeIgniter force_download is not working

PHP SoapClient: set a namespace without prefix

What is the function of the (new Date()).getTime() in PHP?

Laravel print last executed SQL query with Query log

PHP Form Not Inserting

Remove categories with all childs derived from parent category

How to get multiple values with same key from an array PHP

Store multiple fields in JSON column (Nova CMS)

Merge key and value of array index [duplicate]

PHP Array split string and Integers

Symfony 4: "Autowire: you should configure its value explicitly."

PHP array sort and remove duplicates by two field values

How to auto populate preferredCountries from intl-tel-input with db output

Cannot connect to own websocket server when on secured domain

About Contact Privacy policy Terms and conditions