• 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

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

stay with the last 15 elements of an array [duplicate]

PHP SoapClient: set a namespace without prefix

Getting error: CodeIgniterDatabaseBaseResult::getResult in CodeIgniter

Laravel multi auth - Authentication user provider [] is not defined

How to upload mpdf file after generating to s3 bucket in php

Utf8 encoding issue with Laravel

How to map the two arrays with a duplicate value?

How do I refresh a DIV content?

The difference when using if statement true === something() vs something() === true [duplicate]

is there any way to validate a field that sometime is File(image) && sometime is String(Src of same image)

PHP Sorting - getting 10, 11, 12 ... 1, 20, 2 rather than 1, 10, 11, 12 ... 2, 20

Merge key and value of array index [duplicate]

Get all WooCommerce products within own plugin

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

About Contact Privacy policy Terms and conditions