• 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

Render the content of default_filter.php in Joomla front-end

Get image type from base64 encoded src string

Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables 11 [closed]

301 Redirect to remove query string on homepage only

disable two buttons after clicking another button

(Cache::lock()) -> get() -- Under what conditions does it return false?

Is there a way to use Foundry Model for Authentification inside Functional Tests?

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

Issue with laravel eloquent model property

How to get array values using foreach in laravel

Currently Using CodeIgniter Framework i have an Error

Changing font color in javascript

Get WooCommerce product variation attribute terms in admin products general box

Laravel: HTML in notification

Upload a file Using PHP and JavaScript

About Contact Privacy policy Terms and conditions