• 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

Why does using salted hash on python and php give me different results?

CodeIgniter force_download is not working

What is PHP's equivalent of JavaScript's "array.every()"?

woocommerce get_order_report_data to show order_item_id

Read users and passwords from a txt file

PHPExcel How to set conditional formatting to change cell background color based on cells values

how can I set a session variable in Drupal 8 and get it in a php script?

phpmyadmin : Depends: php-twig (>= 2.9) but 2.6.2-2 is to be installed. WHAT?

Facebook SDK error: Cross-site request forgery validation failed. Required param "state" missing from persistent data

PHP 8.1: strftime() is deprecated

I want to display a sweetalert after the inserting of data in my database

Laravel Mix Uncaught ReferenceError: $ is not defined

Laravel UUID generation

php file upload scanning using clamav, permissions on /tmp/

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

About Contact Privacy policy Terms and conditions