• 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

Batch request Google Calendar php API

How to make dot match newline characters using regular expressions

How to modify CSS in a specific page of the WP admin dashboard (backend)

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

Magento 2 - Controller returning blank page

The sum of the user's points

Fatal error: Uncaught mysqli_sql_exception: Unknown database 'test' in ... (How do I fix that? Using PHP)

Laravel Livewire: jQuery not working in child component loaded via @if statement

WHERE IN array binding in DB::raw laravel 5.4

I'm trying to write a clean url for my website using the $_SERVER['REQUEST_URI'] in php

PHP contact form configuration [duplicate]

Converting alphabet letter to alphabet position in PHP [duplicate]

Get sum of arrays inside array

Check if a string contain multiple specific words

How to create a cookie to store the timestamp of when a page is first loaded with php

About Contact Privacy policy Terms and conditions