• 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

PHP - Store information with NO database

Add 2 Webcam in one page with WebcamJS

Mobile browsers are adding .html to filename on download

CSV to PHP class properties

Convert string to lowercase AND then convert it to its original form in PHP, is it possible?

Installing Composer - Internal Error

Codeigniter, Severity: error --> Exception: Too few arguments to function, admin dashboard shows HTTP error 500

display WooCommerce “Add to cart” button with short-code [add_to_cart ] dynamically

Display the WooCommerce product price inside a custom function

How do I refresh a DIV content?

Malformed MIME header error in Symfony 5.3

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

Error when uploading certain .png files "Interlace handling should be turned on when using png_read_image"

Mysqli multi query error

how to use extended ASCII instead of unicode in PHP

About Contact Privacy policy Terms and conditions