• 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

Dropzone: Submit both form data and dropzone at once

Performance of foreach, array_map with lambda and array_map with static function

How can I make Laravel return a custom error for a JSON REST API

Can't exclude directories from .htaccess mobile redirect?

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

SQL AVG() to 2 decimals

how to display a view on laravel 8 and not have a 404 NOT FOUND page?

Add record for each array elements if missing in table

Call authenticate manually in router middleware

How do I do HTTP basic authentication using Guzzle?

Having trouble with PDO queries (Notice: Undefined index)

PHP | "The requested PHP extension bcmath is missing from your system."

Upload a file Using PHP and JavaScript

WHERE IN array binding in DB::raw laravel 5.4

Post Form Data To phpmyadmin Database

About Contact Privacy policy Terms and conditions