• 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

Is it possible to re-use an array taken from PHP via JSON in a $.ajax function?

Get data from accuweather api url

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

How to solve Duplicate entry '0' for key 'PRIMARY' in Wordpress?

loop through an anchor id

Use Python plotly chart in PHP

How can i update or reset my password without entering email field in laravel-8?

Dropzone: Submit both form data and dropzone at once

How to make Canonicals with PHP

Session timeout in Yii2

PHP Get value from JSON [duplicate]

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

How do I get friend list from Friends table with counts of friends of my friends

how to validate form data in codeigniter 4

Redirect to previous page with php

About Contact Privacy policy Terms and conditions