• 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

Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::fetch_assoc() [duplicate]

how to redirect the user back to desired URL after login page in PHP?

Stop caching for PHP 5.5.3 in MAMP

Log a user out of a website when they put their computer to sleep

Unable to guess the mime type as no guessers are available Laravel 5.2

Laravel 5.1 Unknown database type enum requested

Handling expired token in Laravel

Why do I have invalid argument supply for foreach in Laravel for json response? [duplicate]

Split array into 4-element chunks then implode into strings

Parameter is not sent to Laravel route in Ajax

MOODLE: What does it mean to aggregate h5p assets?

best way to store error messages in Laravel (session or variable)

Magento 2 - Controller returning blank page

Getting public posts of a random user from Facebook API

How do I do HTTP basic authentication using Guzzle?

About Contact Privacy policy Terms and conditions