• 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

What is the difference between client-side and server-side programming?

Mobile browsers are adding .html to filename on download

Laravel 5.1 xmlHttpRequest AJAX POST TokenMismatchException

Android Volley getParams() method not getting called for JsonObjectRequest

WordPress Security Standards want me to escape my html, but how to do it correctly?

Project structure for PHP

How to use a PHP MVC Controller, one thats invoked by calling a URL, to call and execute more than one function? [duplicate]

Hide specific products from unlogged users based in product category in WooCommerce

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

I want a way to give path to my files which are outside of public folder in laravel

Yii2: How do I debug console commands?

Utf8 encoding issue with Laravel

Creating live search with AJAX and CodeIgniter

Increase value by 1 on button click

Comma separated list from array with "and" before last element

About Contact Privacy policy Terms and conditions