• 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

Laravel/docker-compose/redis - Class 'Redis' not found

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

How can I remove the "Advanced" panel of all blocks in WordPress block editor?

Symfony process run throws exception - executing on command line works

Appending data to an anchor tag

Mobile browsers are adding .html to filename on download

Laravel Unresolvable dependency resolving [Parameter #0 [ <required> $method ]] in class GuzzleHttpPsr7Request

phpunit - testing is painfully slow

PHP if in_array() how to get the key as well?

Laravel unique validation on multiple columns

php 7 php.ini upload_max_filesize not working

No definition found for function in vendor vscode

Uncaught TypeError: Cannot read property 'length' of null when retrieving tags from wp

Get number of working days between two dates in PHP [duplicate]

How to get the total hour from starting time to end time in php

About Contact Privacy policy Terms and conditions